我正在尝试在地图上放置两个标记。但由于某种原因,其中只有一个作为红色标记图标。 在多台计算机上检查它,必须注意我正在使用WAMP服务器运行。
地图显示为应该,但只有“Marker2”有红色标记图标。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>Customer map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<META HTTP-EQUIV="Refresh" CONTENT="420">
<style type="text/css">
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
.labels {
color: orange;
background-color: black;
font-family: "Lucida Grande", "Arial", sans-serif;
font-size: 10px;
font-weight: bold;
text-align: center;
width: 100px;
border: 2px solid black;
white-space: nowrap;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://jquery-xml2json-plugin.googlecode.com/svn/trunk/jquery.xml2json.js" type="text/javascript" language="javascript"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.0.1/src/markerwithlabel.js"></script>
<script>
var map = null;
function geocodeAddress(lat, lon, image, custname) {
var myLatlng = new google.maps.LatLng(lat,lon);
var marker = new MarkerWithLabel({
position: myLatlng,
map: map,
icon: image,
labelContent: custname,
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
labelStyle: {opacity: 0.75}
});
}
function initialize() {
var chicago = new google.maps.LatLng(0,0);
var mapOptions = {
zoom: 2,
center: chicago,
mapTypeId: google.maps.MapTypeId.HYBRID
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
geocodeAddress (49.0240107,8.7582988,'http://maps.google.com/mapfiles/ms/micons/red-dot.png',"Marker1");
geocodeAddress (30.267153,8.7582988,'http://maps.google.com/mapfiles/ms/micons/red-dot.png',"Marker2");
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
答案 0 :(得分:1)
这一定是个错误(我目前无法告诉你在哪里)。
目前我建议使用发布版本而不是实验性API版本(然后将绘制两个标记):
https://maps.googleapis.com/maps/api/js?v=3&sensor=false