How to use Google map data in other form elements?

How to take Google map coordinates from a map and automatically fill out another form element?

This is my form: http://www.barbadosphonebook.com/list-your-business-for-free/ . At the bottom is the Google map, which, by clicking, displays the coordinates. I would like it to also fill the element below with coordinate data.

My card code:

<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(13.175771, -59.556885);
var myOptions = {
  zoom: 10,
  center: latlng,
  navigationControl: true,
  mapTypeControl: true,
  scaleControl: true,
  mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
//
var contentString = '<strong>Copy the numbers between the brackets</strong><br />';
 google.maps.event.addListener(map, 'click', function(event) {
 new google.maps.InfoWindow ( { position: event.latLng, content: contentString+event.latLng.toString() } ).open(map);
});
}
</script>
0
source share
1 answer

You can try changing the click listener on the map:

google.maps.event.addListener(map, 'click', function(event) {
  new google.maps.InfoWindow ( { position: event.latLng, content: contentString+event.latLng.toString() } ).open(map);
  $('.ginput_container input').val(event.latLng.toString());
}); 
0
source

Source: https://habr.com/ru/post/1767551/


All Articles