0

I can manage to display my image overlay on the map. But a new problem occurs - I can't add a marker on it. I googled it for a while but no luck. Tried to search and mimic the example on documentation and nothing appears to be right.

Here's my code :

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
    function initialize() {
      var newark = new google.maps.LatLng(xx.xxxxx,xx.xxxxx);
      var imageBounds = new google.maps.LatLngBounds(
          new google.maps.LatLng(xx.xxxxx,xx.xxxxx),//SW
          new google.maps.LatLng(xx.xxxxx,xx.xxxxx)//NE
        );

      var mapOptions = {
        zoom: 20,
        center: newark,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }

      var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

      var oldmap = new google.maps.GroundOverlay(
          'images/floor_plan_trans_rotated.gif',
          imageBounds);
      oldmap.setMap(map);
    }

    /*markers*/
      var contentString = '<div id="content">'+
          '<div id="siteNotice">'+
          '</div>'+
          '<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+
          '<div id="bodyContent">'+
          '<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
          'sandstone rock formation in the southern part of the '+
          'Northern Territory, central Australia. It lies 335&#160;km (208&#160;mi) '+
          'south west of the nearest large town, Alice Springs; 450&#160;km '+

</p>'+
      '<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
      'http://en.wikipedia.org/w/index.php?title=Uluru</a> '+
      '(last visited June 22, 2009).</p>'+
      '</div>'+
      '</div>';

  var infowindow = new google.maps.InfoWindow({
      content: contentString,
      maxWidth: 400
  });

  var marker = new google.maps.Marker({
      position: newark,
      map: map,
      title: 'Uluru (Ayers Rock)'
  });
  google.maps.event.addListener(marker, 'click', function() {
    infowindow.open(map,marker);
  });
}

/*markers*/
google.maps.event.addDomListener(window, 'load', initialize);
    </script>
<div id="map-canvas"></div>

For the code above. The map will not display unless I delete those lines between /markers/.

Please suggest. Regards,

4

2 に答える 2

0

このコードの最初の /マーカー/のすぐ上に余分な } はありませんか? それともただ眠いだけなのか……。

私は似たようなことをしており、同じマップ上にgroundOverlayとマーカーを使用して機能しています

于 2013-10-22T10:26:41.293 に答える