0
我試圖在LatLng上居中放置地圖,但我不確定如何這樣做。我有這個IFRAME鏈接:如何居中Google地圖的腳本地圖
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0"
marginwidth="0" src="https://maps.google.es/maps?f=q&source=embed&
hl=es&geocode=&q=Cam%C3%AD+Vell+d'Altea,+33,+L'Alf%C3%A0s+del+Pi&
aq=0&oq=cam%C3%AD+vell+d'altea+33&
sll=40.396764,-3.713379&sspn=13.49375,19.753418&ie=UTF8&hq=&
hnear=Cam%C3%AD+Vell+d'Altea,+33,+03581+L'Alf%C3%A0s+del+Pi,+Alicante,+Comunidad+
Valenciana&t=m&ll=38.570757,-0.076316&spn=0.001743,0.004128&
z=14&layer=c&cbll=38.570736,-0.076335&panoid=DplK9JGOu0KAPqoT95VMgQ&
cbp=12,309.4,,0,8.19&output=svembed"></iframe><br /><small>
我希望它是使用谷歌API的腳本位置。我有這樣的代碼:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
http://maps.googleapis.com/maps/api/js?key=MY_KEY&sensor=false&callback=initialize>
</script>
<script type="text/javascript">
function initialize() {
var myOptions = {
center: new google.maps.LatLng(13.49375,19.75341),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
function loadScript()
{
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.googleapis.com/maps/api/js?key=MY_KEY&sensor=false&callback=initialize";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
但我想把iframe的具體地址給谷歌API我只是複製。我不知道這麼做很熱。
那麼,我該如何鏈接Google maps API上的地圖呢?
非常感謝。
你的意思是用這個腳本代替src嗎?