All Projects → jonataswalker → Ol Geocoder

jonataswalker / Ol Geocoder

Licence: mit
Geocoder Nominatim for OpenLayers

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ol Geocoder

Photon
an open source geocoder for openstreetmap data
Stars: ✭ 1,177 (+644.94%)
Mutual labels:  geocoder
Fcipaddressgeocoder
iOS Geocoder for geocode device IP Address location using GeoIP service(s) and a block-based syntax. 💻🌍
Stars: ✭ 114 (-27.85%)
Mutual labels:  geocoder
Ngx Openlayers
Angular2+ components for Openlayers 4.x
Stars: ✭ 131 (-17.09%)
Mutual labels:  openlayers
Geolocation Python
Geolocation is simple google maps api for python users. This application allows you to get information about given location Application returns such information as: country, city, route/street, street number, reverse geocode, lat and lng, travel distance and time for a matrix of origins and destinations.
Stars: ✭ 77 (-51.27%)
Mutual labels:  geocoder
Osmscout Server
Maps server providing tiles, geocoder, and router
Stars: ✭ 105 (-33.54%)
Mutual labels:  geocoder
Geoext3
A JavaScript framework that combines the GIS functionality of OpenLayers with all features of the ExtJS library
Stars: ✭ 121 (-23.42%)
Mutual labels:  openlayers
Geobed
A simple, lightweight, embedded geocoder for Golang with city level accuracy
Stars: ✭ 60 (-62.03%)
Mutual labels:  geocoder
Ol Contextmenu
Custom Context Menu for OpenLayers
Stars: ✭ 141 (-10.76%)
Mutual labels:  openlayers
Bblocationmanager
A Location Manager for easily implementing location services & geofencing in iOS. Ready for iOS 11.
Stars: ✭ 107 (-32.28%)
Mutual labels:  geocoder
Lizmap Web Client
Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
Stars: ✭ 130 (-17.72%)
Mutual labels:  openlayers
React Places Autocomplete
React component for Google Maps Places Autocomplete
Stars: ✭ 1,265 (+700.63%)
Mutual labels:  geocoder
Mangol
Maps created with Angular & OpenLayers using Material design
Stars: ✭ 92 (-41.77%)
Mutual labels:  openlayers
Ngeo
Library combining OpenLayers and AngularJS
Stars: ✭ 122 (-22.78%)
Mutual labels:  openlayers
React Native Geocoder Reborn
📍 Geocoding services for react-native
Stars: ✭ 77 (-51.27%)
Mutual labels:  geocoder
Data Visualization
Data visualization demos, mainly geographic data.
Stars: ✭ 137 (-13.29%)
Mutual labels:  openlayers
Ol Games
🎮 Game stuff for Openlayers, powered by HTML5, canvas, javascript and Openlayers.
Stars: ✭ 61 (-61.39%)
Mutual labels:  openlayers
Mapboxgeocoder.swift
Address search and reverse geocoding in Swift or Objective-C on iOS, macOS, tvOS, and watchOS
Stars: ✭ 115 (-27.22%)
Mutual labels:  geocoder
Lmgeocoder
Simple wrapper for geocoding and reverse geocoding, using both Google Geocoding API and Apple iOS Geocoding Framework.
Stars: ✭ 141 (-10.76%)
Mutual labels:  geocoder
Openlayers Editor
OpenLayers Editor
Stars: ✭ 138 (-12.66%)
Mutual labels:  openlayers
Placepicker
Free Android Map Place Picker alternative using Geocoder instead of Google APIs
Stars: ✭ 126 (-20.25%)
Mutual labels:  geocoder

OpenLayers Control Geocoder

build status npm version license dependency status devDependency status

A geocoder extension for OpenLayers. Requires OpenLayers v3.11.0 or higher.

geocoder anim

Demo

You can see here a demo or on jsFiddle if you prefer. There is also a demo of creating a custom provider

Providers

The plugin supports (for now) the following providers:

Custom Providers

You can also write your own provider, passing an instance of it to the Geocoder constructor via the provider property of the options argument.

For an example of defining and using a custom provider see examples/custom-provider.js

Custom providers must implement the following methods:

getParameters(options)

  • options {Object}
    • query Search string entered by the user;
    • lang {string} Preferable language;
    • limit {number} Limit of results;

handleResponse(results)

  • results {Object} Parsed JSON response from API call

How to use it?

NPM

npm install ol-geocoder

CDN Hosted - jsDelivr

Load CSS and Javascript:

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/ol-geocoder.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/ol-geocoder"></script>
CDN Hosted - UNPKG

Load CSS and Javascript:

<link href="https://unpkg.com/ol-geocoder/dist/ol-geocoder.min.css" rel="stylesheet">
<script src="https://unpkg.com/ol-geocoder"></script>
Self hosted

Download latest release and (obviously) load CSS and Javascript.

Instantiate with some options and add the Control
var geocoder = new Geocoder('nominatim', {
  provider: 'mapquest',
  key: '__some_key__',
  lang: 'pt-BR', //en-US, fr-FR
  placeholder: 'Search for ...',
  targetType: 'text-input',
  limit: 5,
  keepOpen: true
});
map.addControl(geocoder);
Listen and do something when an address is chosen
geocoder.on('addresschosen', function(evt){
  var feature = evt.feature,
      coord = evt.coordinate,
      address = evt.address;
  // some popup solution
  content.innerHTML = '<p>'+ address.formatted +'</p>';
  overlay.setPosition(coord);
});

API

Constructor

new Geocoder(type, options)

  • type {String} - Maybe later we will have other types like 'reverse'. So for now just pass 'nominatim'.

  • options is an object with the following possible properties:

    • provider : 'osm' (default), 'mapquest', 'photon', 'pelias', 'bing', 'opencage', custom provider instance; Your preferable provider;
    • key : ''; API Key if required;
    • autoComplete : false; Search as you type;
    • autoCompleteMinLength: 2; The minimum number of characters to trigger search;
    • autoCompleteTimeout : 200; The mimimum number of ms to wait before triggering search if autoComplete is on and minimum number of characters is satisfied;
    • placeholder : 'Search for an address'; Placeholder for text input;
    • targetType : 'glass-button'; Can also be 'text-input';
    • featureStyle : ol.style.Style; Feature style;
    • lang : 'en-US'; Preferable language;
    • limit : 5; Limit of results;
    • countrycodes : ''; Only valid for osm and mapquest; Limit search results to a specific country (or a list of countries). This is an [ISO 3166-1alpha2 code] (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2), e.g. gb for the United Kingdom, br for Brazil, etc;
    • keepOpen : false; Whether the results keep openned;
    • preventDefault : false; Whether panning (and creating marker) when an address is chosen;
    • debug : false; If true logs provider's response;

Instance Methods

getLayer()

Returns the layer {ol.layer.Vector} created by Geocoder control.

getSource()

Returns the source {ol.source.Vector} created by Geocoder control.

setProvider(provider)

@param {String} provider

Sets a new provider.

setProviderKey(key)

@param {String} key

Sets provider key.

Events

Triggered when an address is chosen
geocoder.on('addresschosen', function(evt) {
  // it's up to you
  console.info(evt);
});
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].