javascript - Leaflet.Geosearch: get lon/lat from address -


without knowledge of js, forced implement map (osm via leaflet) on webpage. on map, there should marker actual address of person. address saved string in database. can see map, can add marker it, after that, i'm lost.

i've tested leaflet-geocoding-plugins, must confess, they're not simple enough actual programmming experience.

another question same problem, didn't understand, how lon/lat address l.geosearch-plugin leaflet.

can provide me example of looking address (via osmn or else, not google/bing or other api-key-needy provider), converting lon/lat , add marker on map?

first have include .js files of geocoder in head of html code, example have used one: https://github.com/perliedman/leaflet-control-geocoder. this:

<script src="control.geocoder.js"></script> 

then have initialize geocoder in .js:

geocoder = new l.control.geocoder.nominatim(); 

then have specify address looking for, can save in variable. example:

var yourquery = (addres of person);     

(you can address out of database, save in variable)

then can use following code 'geocode' address latitude / longitude. function return latitude / longitude of address. can save latitude / longitude in variable can use later marker. have add marker map.

geocoder.geocode(yourquery, function(results) {            latlng= new l.latlng(results[0].center.lat, results[0].center.lng);        marker = new l.marker (latlng);        map.addlayer(marker); }); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -