How to link multiple marker in dynamic mode using jquery on google maps

I need to snap the Multiple Marker on a Google map based on a given latitude and longitude, and also snap a mark information window.

I have a link to this link

And I tried this code:

var myLatLng = new google.maps.LatLng(this.Latitude, this.Longtitude); var contentString = '<span style="color:green;font-size:10pt;">Hospital Name:' + this.hospitalName + '</span><br />Address:<br />' + this.cityName + this.stateName + '<br/><br/>'; //this.hospitalName + '</br>' + this.cityName + '</br>' + this.stateName; var infowindow = new google.maps.InfoWindow(); var marker = new google.maps.Marker({ position: myLatLng, map: map, icon: image, shape: shape }); google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(contentString); infowindow.open(map, this); }); 
+4
source share
1 answer

You can use something like this,

 $.each($.parseJSON(data), function() { var myLatLng = new google.maps.LatLng(this.Latitude, this.Longtitude); var contentString = '<span style="color:green;font-size:10pt;">Hospital Name:' + this.hospitalName + '</span><br />Address:<br />' + this.cityName + this.stateName + '<br/><br/>'; this.hospitalName + '</br>' + this.cityName + '</br>' + this.stateName; var infowindow = new google.maps.InfoWindow(); var marker = new google.maps.Marker({ position: myLatLng, map: map, icon: image, shape: shape }); google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(contentString); infowindow.open(map, this); }); }); 
+3
source

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


All Articles