我正尝试使用Google Maps API设置一个简单的页面,以在位置上显示标记。但是,我没有得到这个代码,这是基于谷歌示例代码here。我改变了源从使用Google Maps API显示标记
"https://maps.googleapis.com/maps/api/js?key=API_KEY&sensor=false"
到
"http://maps.google.com/maps/api/js?sensor=false"
,因为有人建议here避免使用API密钥的目的。 var标记声明从谷歌here复制。什么必须改变我的标记出现?
<!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.google.com/maps/api/js?sensor=false"></script>
</script>
<script type="text/javascript">
function initialize() {
var location = new google.maps.LatLng(59.272, 10.418);
var mapOptions = {
center: location,
zoom: 8
};
var marker = new google.maps.Marker({
position: location,
map: map,
title: 'Hello World!'
});
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"/>
</body>
</html>
伟大的思想:)。 – Swires
谢谢@Andy。你节省了我的时间。我还有一个疑问。我想要显示标记窗口的详细信息。你能建议我吗? –