javascript - Allow a user to select a location by marker or entering the address -
looking @ https://developers.google.com/maps/documentation/javascript/examples/directions-simple still can't understand how can give user ability select location either dragging , dropping marker or entering address , show selected location clicking on button.
any suggestions?
you can handle map click event , lat lng , create marker , show on map.
google.maps.event.addlistener(map, 'click', function( event ){ alert( "latitude: "+event.latlng.lat()+" "+", longitude: "+event.latlng.lng() ); var mylatlng = new google.maps.latlng(event.latlng.lat(),event.latlng.lng() ); var marker = new google.maps.marker({ position: mylatlng, map: map, title: 'hello world!' }); });
use mylatlng calculate distance. additionally, if want show marker when user hovers on map handle mouseover event of map. list of events see here: https://developers.google.com/maps/documentation/javascript/events
Comments
Post a Comment