All Projects → OpenCageData → leaflet-opencage-search

OpenCageData / leaflet-opencage-search

Licence: BSD-2-Clause license
A Leaflet geocoding control that uses the OpenCage geocoding API

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to leaflet-opencage-search

Leaflet Geosearch
(Leaflet) GeoSearch / GeoCode provider
Stars: ✭ 666 (+3600%)
Mutual labels:  geocoding, leaflet
geocoder
Geocoder is a Typescript library which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding manipulations
Stars: ✭ 28 (+55.56%)
Mutual labels:  geocoding, geocoder
Geocoder
🌎 GoLang package that provides an easy way to use the Google Geocoding API
Stars: ✭ 23 (+27.78%)
Mutual labels:  geocoding, geocoder
Gisgraphy
geocoding and geolocalisation webservices for Geonames, Openstreetmap, Openaddresses, Tiger and quattroshapes data
Stars: ✭ 275 (+1427.78%)
Mutual labels:  geocoding, geocoder
Lmgeocoder
Simple wrapper for geocoding and reverse geocoding, using both Google Geocoding API and Apple iOS Geocoding Framework.
Stars: ✭ 141 (+683.33%)
Mutual labels:  geocoding, geocoder
Geopy
Geocoding library for Python.
Stars: ✭ 3,512 (+19411.11%)
Mutual labels:  geocoding, geocoder
Photon
an open source geocoder for openstreetmap data
Stars: ✭ 1,177 (+6438.89%)
Mutual labels:  geocoding, geocoder
python-opencage-geocoder
Python module to access the OpenCage geocoding API
Stars: ✭ 54 (+200%)
Mutual labels:  geocoding, opencage
Dtp Stat
Карта ДТП
Stars: ✭ 141 (+683.33%)
Mutual labels:  geocoding, leaflet
Mapboxgeocoder.swift
Address search and reverse geocoding in Swift or Objective-C on iOS, macOS, tvOS, and watchOS
Stars: ✭ 115 (+538.89%)
Mutual labels:  geocoding, geocoder
Fccurrentlocationgeocoder
iOS Geocoder for forward geocode and reverse geocode user's current location using a block-based syntax. 📍🌍
Stars: ✭ 268 (+1388.89%)
Mutual labels:  geocoding, geocoder
local-reverse-geocoder
Local reverse geocoder for Node.js based on GeoNames data
Stars: ✭ 155 (+761.11%)
Mutual labels:  geocoding, geocoder
kirby-locator
A simple map & geolocation field, built on top of open-source services and Mapbox. Kirby 3 only.
Stars: ✭ 83 (+361.11%)
Mutual labels:  geocoding, leaflet
Geo Golang
Go library to access geocoding and reverse geocoding APIs
Stars: ✭ 394 (+2088.89%)
Mutual labels:  geocoding, geocoder
NominatimGeocoderBackend
UnifiedNlp geocoder backend that uses the OSM Nominatim service
Stars: ✭ 49 (+172.22%)
Mutual labels:  geocoding, geocoder
Pelias Android Sdk
Android sdk for pelias
Stars: ✭ 20 (+11.11%)
Mutual labels:  geocoding, geocoder
Osmunda
An offline geocode library for android, powered by SQLite, using osm data. 离线地理编码Android库,基于SQLite,使用开放街道地图数据。
Stars: ✭ 37 (+105.56%)
Mutual labels:  geocoding, geocoder
php-opencage-geocode
PHP library to access the OpenCage geocoding API
Stars: ✭ 26 (+44.44%)
Mutual labels:  geocoding, opencage
Fcipaddressgeocoder
iOS Geocoder for geocode device IP Address location using GeoIP service(s) and a block-based syntax. 💻🌍
Stars: ✭ 114 (+533.33%)
Mutual labels:  geocoding, geocoder
Mimirsbrunn
Geocoding and reverse-geocoding (with OSM data)
Stars: ✭ 165 (+816.67%)
Mutual labels:  geocoding, geocoder

OpenCage Data Geocoding Control for Leaflet

A Leaflet geocodig control that uses OpenCage Data's geocoder.

Check out a demo page in /demo. Or take a look at the live demo.

Installation

You have three options

or

or

  • Install (using the old plugin's name) with Bower : $ bower install Leaflet.OpenCage.Search

Configuration

The control uses two image files that it expects to find in a directory with a path relative to the control's CSS files as ../images. If you've installed the control using Bower you'll find these in bower_components/Leaflet.OpenCage.Geocoding/dist/images/. If you've cloned the control's GitHub repository or downloaded and unpacked an archive from GitHub, you'll find these in dist/images.

Whichever installation method you've chosen, you'll need to move a copy of these two image files to a directory relative to the location of the control's CSS files.

Usage

Load the plugin's CSS and JavaScript files:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/opencagedata/[email protected]/dist/css/L.Control.OpenCageGeocoding.min.css" />
<script src="https://cdn.jsdelivr.net/gh/opencagedata/[email protected]/dist/js/L.Control.OpenCageGeocoding.min.js"></script>

Add the plugin's control to an L.Map instance:

var map = L.map('map').setView([51.52255, -0.10249], 13);
var options = {
  key: 'your-api-key-here',
  limit: 10,
};
var control = L.Control.openCageGeocoding(options).addTo(map);
L.tileLayer('http://tile.osm.org/{z}/{x}/{y}.png', {
  attribution:
    '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
}).addTo(map);

Customizing

By default, when a geocoding result is found, the control will center the map on it and place a marker at its location. This can be customized by overwriting the control's markGeocode function, to perform any action desired.

For example:

var control = L.Control.openCageGeocoding(options).addTo(map);

control.markGeocode = function (result) {
  var bbox = result.bbox;
  L.polygon([
    bbox.getSouthEast(),
    bbox.getNorthEast(),
    bbox.getNorthWest(),
    bbox.getSouthWest(),
  ]).addTo(map);
};

This will add a polygon representing the result's boundingbox when a result is selected.

Options

You can overwrite the following options, for example to translate.

var options = {
    key: '', // your OpenCage API key
    limit: 5 // number of results to be displayed
    position: 'topright',
    placeholder: 'Search...', // the text in the empty search box
    errorMessage: 'Nothing found.',
    showResultIcons: false,
    collapsed: true,
    expand: 'click',
    addResultToMap: true, // if a map marker should be added after the user clicks a result
    onResultClick: undefined, // callback with result as first parameter
    resultExtension: {
        geohash: "annotations.geohash",
        what3words: "annotations.what3words",
        addressComponents: "components"
    } //if additional attributes from OpenCage search API should be added to the result
};

var control = L.Control.openCageGeocoding(options).addTo(map);

Contributing

See CONTRIBUTING.md file.

Dependencies

Leaflet version 0.7+

License

See LICENSE file.

Who is OpenCage GmbH?

We run the OpenCage Geocoder. Learn more about us.

We also run Geomob, a series of regular meetups for location based service creators, where we do our best to highlight geoinnovation. If you like geo stuff, you will probably enjoy the Geomob podcast.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].