75
rated 0 times
[
81]
[
6]
/ answers: 1 / hits: 34250
/ 8 Years ago, wed, april 27, 2016, 12:00:00
The following code allows to get the coordinates, on click.
But how to get the address or city name or region name or country on click on the map, with Google Maps API?
var myLatlng = new google.maps.LatLng(41.38,2.18);
var myOptions = { zoom: 13, center: myLatlng}
var map = new google.maps.Map(document.getElementById(map-canvas), myOptions);
google.maps.event.addListener(map, 'click', function(event) {alert(event.latLng);});
html, body, #map-canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src=https://maps.googleapis.com/maps/api/js?sensor=false&libraries=geometry,places&ext=.js></script>
<div id=map-canvas></div>
More From » google-maps