我的地图在正确的地方吗?谷歌地图

时间:2011-09-10 20:17:32

标签: javascript google-maps

此代码生成一个地图(至少假设)删除兴趣点,然后将DB中的标记放在地图上。加载地图后,Chrome会向我显示latlng is not defined错误。

 function map_initialize() {    
 var removePOI = [
            {
        featureType: "all",
        stylers: [
            { saturation: -80 }
                    ]
            },{
            featureType: "poi.business",
            elementType: "labels",
            stylers: [
        { visibility: "off" }
                        ]
            },
            {
        featureType: "poi.park",
        stylers: [
            { hue: "#649E55" },
            { saturation: 40 }
                    ]
            }
            ];            

        var RemovePOI = new google.maps.StyledMapType(removePOI,
            {name: "Remove_POI"});
            var myOptions = {
                zoom: 16,
                center: latlng,
                disableDefaultUI: true,
                 mapTypeControlOptions: {
                mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'Remove_POI']
            }
            }
            map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
            /* more map POi stuff */        
            map.mapTypes.set('Remove_POI', RemovePOI);
            map.setMapTypeId('Remove_POI');                 


            $('#map-info').empty(); 
            $('#map-info').slideDown("slow");   
            $('#map-info').append("<p class='maptitle'>"+name+"</p>");
            $('#map-info').append("<p class='address'>"+address+"<br /");
            $('#map-info').append(distance+" from where you are.</p>");


            var radius = 25;
            var searchUrl = 'http://servername.co.nz/singlesiteXML.php?siteid=<?echo $_SESSION['siteid'] ?>'
            jQuery.get(searchUrl, {}, function(data) {
            jQuery(data).find("marker").each(function() {

        var marker = jQuery(this);
        var id = marker.attr("id");
            var name = marker.attr("name");
            var address = marker.attr("address"); 
            var distance = marker.attr("distance"); 
            var latlng = new google.maps.LatLng(parseFloat(marker.attr("lat")),parseFloat(marker.attr("lng")));
            var marker = new google.maps.Marker({position: latlng, map: map,icon: 'http://servername.co.nz/markers/'+marker.attr("markerIcon")});


            }); 
            });
  }

0 个答案:

没有答案