0.0.9 • Published 4 years ago

leaflet-google-places-autocomplete v0.0.9

Weekly downloads
925
License
ISC
Repository
github
Last release
4 years ago

Leaflet Google Places Autocomplete

Simple extension to add Google Places autocomplete into map.

Installation

Bower

bower install --save leaflet-google-places-autocomplete

NPM

npm install --save leaflet-google-places-autocomplete

Usage

Make sure you have Google Places library with valid API key loaded on page.

    <script src="https://maps.googleapis.com/maps/api/js?key=<key>&libraries=places"></script>
new L.Control.GPlaceAutocomplete().addTo(map);
new L.Control.GPlaceAutocomplete({
	callback: function(place){
		var loc = place.geometry.location;
		map.setView( [loc.lat(), loc.lng()], 18);
	}
}).addTo(map);

API

Options

These options can be set up when creating the control with autocompleteOptions.

OptionDefaultVersionDescription
positiontoprightv0.0.5any valid LeafLet position
prependtrue:boolv0.0.5If true, control will prepended to other existing controls, if false, control will be appended
callback-v0.0.5any valid function as callback. By default internal callback is set and just pan the map to found position
autocomplete_options{}v0.0.5default options for google autocomplete
collapsed_modefalse:boolv0.0.6if set to true, then just click-able icon will be displayed
placeholdernull:stringv0.0.9custom placeholder for input text