使用 google map API V3,我创建了一个 html 页面。它完美地加载了 gmap,我设置按钮在 iframe 中加载另一个基于 web 的地图(mapmyindia.com)。基本上它从 gmap 获取参数(纬度/经度)并获取到该帧进行加载。它适用于第一次单击并导航当前 gmap 位置。在将它平移到另一个位置并单击提交按钮后,它应该将 gmap 的当前位置加载到 Iframe 中。但是第二次就不行了。请检查我的代码和帮助......!
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
var map;
var marker
function initialize()
{
var mapOpt = {
center:new google.maps.LatLng(20.6588,80.9562),
zoom:6,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map=new google.maps.Map(document.getElementById("googleMap"),mapOpt);
google.maps.event.addListener(map, 'mousemove', function(event) {
document.getElementById("pp").value = map.getCenter().lat() + "," +map.getCenter().lng();
});
}
google.maps.event.addDomListener(window, 'load',initialize);
function copyText()
{
var xy=map.getCenter().lat()+ "," +map.getCenter().lng();
document.getElementById("latlng").value=xy;
document.getElementById("Zoom").value=map.getZoom();
}
function copyText1()
{
var xy=map.getCenter().lat()+ "," +map.getCenter().lng();
}
function OfferTwo(){
var mmy = map.getCenter().lng() + "," +map.getCenter().lat();
var sUrl = document.getElementById('offer2').src;
//var Zm= map.getZoom();
var Zm= '8';
document.getElementById('offer2').src = 'http://maps.mapmyindia.com/embed.html#current:'+Zm+','+mmy;
}
</script>
</head>
<body>
<input type= "text" ID=latlng>
<input type="text" ID=Zoom size="5" maxlength="2">
<input type ="text" ID="pp" >
<button onClick="copyText()">Submit</button>
<button onClick="OfferTwo()">Go To MMy</button>
<p Id="mmyurl">MamMyIndia Link</p>
<br><br>
<div id="googleMap"style="width:700px;height:500px;"></div>
<iframe id="offer2" Width="700" Height ="500"></iframe>
</body>
</html>