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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -