簡體   English   中英

Google Maps API僅顯示一個標記圖標

[英]Google Maps API only one marker icon appears

我正在嘗試在地圖上放置兩個標記。 但是由於某種原因,其中只有一個作為紅色標記圖標。 在多台計算機上檢查了它,必須注意我正在使用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>

這一定是一個錯誤(我目前無法告訴您在哪里)。

現在,我建議使用發布版本而不是實驗性的API版本(然后將繪制兩個標記):

https://maps.googleapis.com/maps/api/js?v=3&sensor=false

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM