0
 <script type="text/javascript">

        function initialize1() {

            var markers = JSON.parse('<%=FarmerMap()%>');
            var mapOptions = {
                center: new google.maps.LatLng(markers[0].Lats, markers[0].Longs),
                zoom: 10,
                mapTypeControl: true,
                mapTypeControlOptions: {
                    style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
                    position: google.maps.ControlPosition.TOP_RIGHT
                },
                mapTypeId: google.maps.MapTypeId.ROADMAP


            };



            var infoWindow = new google.maps.InfoWindow();
            var map = new google.maps.Map(document.getElementById("FarmerMap"), mapOptions);
            for (i = 0; i < markers.length; i++) {
                var data = markers[i]
                var myLatlng = new google.maps.LatLng(data.Lats, data.Longs);
                var marker = new google.maps.Marker({
                    position: myLatlng,
                    map: map,
                    title: data.title,
                    animation: google.maps.Animation.BOUNCE

                });
                (function(marker, data) {


                    google.maps.event.addListener(marker, "click", function(e) {
                        infoWindow.setContent(data.FarmerName,data.Area);
                        infoWindow.open(map, marker);
                    });
                })(marker, data);
            }
            return true;
        }
    </script>

我的问题是 infoWindow.setContent(data.FarmerName,data.Area); 不会显示两列值..它只显示一列名称..这意味着仅 FarmerName...我还想显示farmername 和 area...

4

1 回答 1

1

试试这个:

google.maps.event.addListener(marker, "click", function(e) {
                    infoWindow.setContent('<p>' + data.FarmerName 
                            + ', ' + data.Area + '</p>');
                    infoWindow.open(map, marker);
                });
于 2013-09-30T06:19:41.070 回答