[英]Can I load a google map into a div container?
I have current code that loads my google map into a colorbox but I'd like to load it into a div tag that can be loaded into a colorbox from another page. 我有当前代码,可将我的Google地图加载到颜色框,但我想将其加载到div标签,该标签可从另一页加载到颜色框。
Here is my current colorbox code (works) 这是我当前的颜色框代码(有效)
$.fn.colorbox({width:"643px", height: "653px", inline:true, href:"#map_container"}, function() {
$.getJSON('users.php', function(data){
initialize();
setMarkers(map, data);
});
});
Here is my attempt at loading the same data into my div container (doesn't work, returns a 403 error) 这是我尝试将相同的数据加载到div容器中(无效,返回403错误)
$('#map_container').load('users.php', function(data){
var jqxhr = $.getJSON(data);
initialize();
setMarkers(map, jqxhr);
});
Any idea why I'm getting a 403 error or have I missed something? 知道为什么我会收到403错误或我错过了什么吗?
$('#foo').load('users.php') will load the data from users.php into the #foo div. $('#foo')。load('users.php')会将来自users.php的数据加载到#foo div中。
You want to do the .getJSON call with a callback, something along the lines of 您想要使用回调进行.getJSON调用,类似
jQuery.getJSON("users.php", {}, function(data, status) {
initialize(); // should setup #map_container with a map with the maps API
setMarkers(map, data);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.