4

我需要根据给定的纬度和经度在谷歌地图中绑定“多个标记”,并绑定标记信息窗口。

我已审阅此链接

我已经尝试过这段代码:

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

1 回答 1

3

你可以使用这样的东西,

$.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);
                            });


});
于 2013-05-24T11:40:09.080 回答