我只是在谷歌网站上关于如何使用他们的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"
src="http://maps.googleapis.com/maps/api/js?key=personalKey&sensor=false&language=ar®ion=ES">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
从它所说的应该简单起作用。我试图让西班牙在地图上展示而不是当前的选择。
以下链接:https://developers.google.com/maps/documentation/javascript/basics
谢谢,
答案 0 :(得分:1)
您正尝试通过设置区域来设置地图的位置。您仍然需要将坐标更改为西班牙的坐标。
尝试:40.6986°N,3.2949°W
答案 1 :(得分:1)
根据LatLng,将您传递给google.maps.LatLng()
的值更改为接近您想要显示的位置(例如,goggle.maps.LatLng(40.813797402839086, -3.62546328124995)
为马德里。