内谷歌地图API的JavaScript我使用谷歌地图的JavaScript API显示的地图 - https://developers.google.com/maps/documentation/javascript/jQuery的对话窗口
有一些API中的某些功能,我需要的是静态的地图所没有的。
所以这个页面正常工作作为一个独立的页面:
<!DOCTYPE html>
<html>
<head>
<title>Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
function initialize() {
// Set map coordinates with lat and lng
var cord = new google.maps.LatLng(28.545078,-81.377196);
// Set map options
var mapOptions = {
zoom: 15,
center: cord,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Set map
var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
// Set map marker
var marker = new google.maps.Marker({
position: cord,
map: map,
title: 'Test'
});
}
// Load Map
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"style="width:600px; height:500px"></div>
</body>
</html>
我需要得到该页面jQuery的对话窗口内工作。
我所说的对话框和加载外部页面这样的:那么
<script type="text/javascript">
$(document).ready(function() {
$("#cc").click(function(){
$("#detailWin").dialog({
autoOpen: false,
modal: true,
width:700,
height:600,
show: "fade",
close: "fade",
open: function()
{
$(this).load('p2.php');
}
});
$('#detailWin').dialog("open");
});
});
</script>
当我包括第一套代码放到页面maps.php这是行不通的。我意识到我不想在包含的页面中包含所有和标签。我一直在尝试很多不同的方式,我无法让地图加载到对话窗口中。
我试过用jQuery加载地图API URL $.getScript()
但它没有帮助。
如果任何人都可以帮助我找出最佳方法来获得这项工作,将不胜感激,因为我卡住了。
谢谢!
UPDATE:
我最终得到像这样的工作(这第二页maps.php):
<script type="text/javascript">
$(document).ready(function() {
function initialize() {
// Set map coordinates with lat and lng
var cord = new google.maps.LatLng(28.545078,-81.377196);
// Set map options
var mapOptions = {
zoom: 15,
center: cord,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Set map
var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
// Set map marker
var marker = new google.maps.Marker({
position: cord,
map: map,
title: 'Test'
});
}
// Load Map
google.maps.event.addDomListener(window, 'load', initialize);
initialize();
});
</script>
<div>
<div id="map-canvas"style="width:600px; height:500px"></div>
</div>
您选择的浏览器调试器中的任何错误消息? – BLSully 2013-05-14 16:07:03
不,几乎所有我尝试的方式我只是得到一个空白页面,Firebug显示没有错误。谢谢 – Sequenzia 2013-05-14 16:24:17