我想通过使用Google Maps API 3点击标记打开一个新窗口.
不幸的是,Google Maps API的示例并不多,我发现了这段代码:
google.maps.event.addListener(marker, 'click', function() {
window.location.href = marker.url;
});
Run Code Online (Sandbox Code Playgroud)
当我用循环创建标记时如何使用它?我在很多方面都尝试过它而且没有能力.
这是我的代码 - 我简单而简短:
<!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?sensor=false"></script>
<script type="text/javascript">
var points = [
['name1', 59.9362384705039, 30.19232525792222, 12],
['name2', 59.941412822085645, 30.263564729357767, 11],
['name3', 59.939177197629455, 30.273554411974955, 10]
];
function setMarkers(map, locations) {
var shape = { …Run Code Online (Sandbox Code Playgroud) javascript google-maps google-maps-api-3 google-maps-markers