0

我正在使用谷歌地图 api v3。它工作正常,但地图图像不起作用你能告诉实际问题是什么。我第一次使用谷歌地图API,所以请帮助提前谢谢-演示

我使用的代码---

<style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map { height: 80%;width:80% }
    </style>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false">
    </script>
    <script type="text/javascript">
    var map;
    var locations = [
  [' 1', 33.1890542, 151.274856, 'http://localhost/liveMap/app/webroot/favicon.ico'],
  [' 2', 33.0923036, 151.259052, 'http://localhost/liveMap/app/webroot/img/cake.icon.png'],
  [' 3', 34.9028249, 151.157507, 'http://localhost/liveMap/app/webroot/img/test-error-icon.png'],
  [' 4', 33.480010128657071, 151.28747820854187, 'http://localhost/liveMap/app/webroot/img/test-fail-icon.png'],
  [' 5', 33.950198, 151.259302, 'http://localhost/liveMap/app/webroot/img/test-pass-icon.png']];
  function initialize() {
    var myOptions = {
      center: new google.maps.LatLng(33.890542,151.274856),
      zoom: 8,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map"),myOptions);
    setMarkers(map,locations)
  }
  function setMarkers(map,locations){
      var marker, i
for (i = 0; i < locations.length; i++)
 {  
 var loan = locations[i][0]
 var lat = locations[i][1]
 var long = locations[i][2]
 var add =  locations[i][3]

 latlngset = new google.maps.LatLng(lat, long);

  var marker = new google.maps.Marker({  
          map: map, title: loan , position: latlngset ,icon : add ,draggable:true,
        });
        map.setCenter(marker.getPosition())


        var content = "Number: " + loan +  '</h3>'     

  var infowindow = new google.maps.InfoWindow()

google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){ 
        return function() {
           infowindow.setContent(content);
           infowindow.open(map,marker);
        };
    })(marker,content,infowindow)); 

  }
  }
</script>
<body>
<div><a href="javascript:void(0)" onclick="return initialize()">Click Me</a></div>
<div id="map"></div>

提前致谢。

4

1 回答 1

0

如果您尝试在浏览器窗口中查看图像,它会显示吗?

http://localhost/liveMap/app/webroot/img/cake.icon.png

因为您使用的是本地主机地址,所以我们无法分辨。

于 2013-02-28T08:54:29.077 回答