Javascript 谷歌地图API V3上未放置标记

Javascript 谷歌地图API V3上未放置标记,javascript,jquery,google-maps-api-3,Javascript,Jquery,Google Maps Api 3,我有两个函数initialize()和placeMarker()现在发生的是,在initialize方法中,每当页面加载时调用它,它初始化地图,然后它向php脚本发送一个请求,php脚本将发送经度和纬度位置作为响应 脚本的响应是正确的,因为我已经使用alertbox进行了检查 当我从$外部调用placeMarker函数时,每个都可以工作 但是如果我从$内部调用它,则每个都不会放置标记 function initialize(latitude,longitude) { geocoder =

我有两个函数
initialize()
placeMarker()
现在发生的是,在
initialize
方法中,每当页面加载时调用它,它初始化地图,然后它向php脚本发送一个请求,php脚本将发送经度和纬度位置作为响应

脚本的响应是正确的,因为我已经使用alertbox进行了检查

当我从
$外部调用
placeMarker
函数时,每个
都可以工作

但是如果我从
$内部调用它,则每个
都不会放置标记

function initialize(latitude,longitude)
{
    geocoder = new google.maps.Geocoder();

    //Initial Map Variables
    var mymap={
            zoom:8,
            center:new google.maps.LatLng(latitude,longitude),
            mapTypeId:google.maps.MapTypeId.ROADMAP
        };  

        //Initialize Map
        map=new google.maps.Map(document.getElementById("map_canvas"),mymap);

           //  placeMarker(latitude,longitude);
           //  placeMarker(latitude + 0.2,longitude + 0.2);     When these two are called it places the marker on the map

    $.ajax({
          type: 'GET',
          url: "Profile_Control.php",
          data: "ajaxRequest=yes&id="+document.getElementById("compid").value,
          success:function(data){
             var parsedData= $.parseJSON(data);
            $.each(parsedData,function(){
                placeMarker(this['lat'],this['lng']);           

        //not place the marker on the map.
            });
        }
        }); 
}


//Place the marker and update the array.
function placeMarker(latitude,longitude)
{
    var myLatLng = new google.maps.LatLng(latitude,longitude);

            var marker = new google.maps.Marker({
                    map: map,
                    position:myLatLng,
                }); 
}
试一试


浏览器是否有错误?如何检查?浏览器工作正常。如果您使用的是Chrome,请按Ctrl+Shift+J打开控制台,查看是否有错误。是的,我将此错误
资源解释为图像,但使用MIME类型text/html传输:http://maps.googleapis.com/maps/gen_204?ev=api_viewport&cad=src:apiv3,ts:133811915974“
。能否使用
控制台.log
来记录
parsedData
的值?请尝试
placeMarker(parsedData[j].lat,parsedData[j].long)然后。另外,您使用的是哪个版本的jQuery?
$(parsedData).each(function(j) {
  placeMarker(parsedData[j]['lat'],parsedData[j]['long']);
});