UNPKG

leaflet-google-places-autocomplete

Version:
47 lines (37 loc) 1.53 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Leaflet Google Places Autocomplete</title> <!-- leaflet 0.7 --> <link rel="stylesheet" href="https://unpkg.com/leaflet@0.7.7/dist/leaflet.css" /> <script src="https://unpkg.com/leaflet@0.7.7/dist/leaflet.js"></script> <!-- leaflet 1.0.1 <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.1/dist/leaflet.css" /> <script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"></script> --> <script src="../src/js/leaflet-gplaces-autocomplete.js"></script> <link rel="stylesheet" href="../src/css/leaflet-gplaces-autocomplete.css" /> <script src="https://maps.googleapis.com/maps/api/js?libraries=places"></script> </head> <body> <div id="map" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div> <script type="text/javascript"> // init map var map = L.map('map').setView([51.505, -0.09], 13); var tiles = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { maxZoom: 18, attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }); map.addLayer(tiles); new L.Control.GPlaceAutocomplete({ callback: function(place){ var loc = place.geometry.location; map.panTo([loc.lat(), loc.lng()]); map.setZoom(18); } }).addTo(map); </script> </body> </html>