Google Maps API不显示我的标记

时间:2019-02-14 17:28:48

标签: javascript api maps

我目前正在为学校项目创建一个网站。我创建了一个代码,该代码应显示带有一些标记和代表国家之间边界的线的地图。问题是,当我加载此地图时,我可以显示线条,但标记全部消失。任何帮助将不胜感激。我已经拥有一个有效的密钥。

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Google Maps</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=MYKEY" type="text/javascript"></script>
  </head>
  <body onunload="GUnload()">
    <div id="map" style="width: 768px; height: 512px"></div>
      <form action="#">
        <input type="button" value="hide" onclick="map.removeOverlay(kml)" />
        <input type="button" value="show" onclick="map.addOverlay(kml)" />
      </form>
    <script type="text/javascript">
      var mapProp= {
        center:new google.maps.LatLng(41.8919300, 12.5113300),
        zoom:3,
        streetViewControl: false,
      };
      var map = new google.maps.Map(document.getElementById("map"), mapProp);
      var kml = new GGeoXml("http://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml");
      map.addOverlay(kml);
      var imageitaly = 'https://MYWEBSITE/mypath/wp-content/uploads/2019/02/italyscaled.png';
      var Rome = {lat: 41.6500086, lng: 12.5113300};
      var markerrm = new google.maps.Marker({
          position: Rome,
          map: map,
          title: 'Italia',
      	icon: imageitaly
        });
        markerrm.addListener('click', function() {
                window.location.href = ('https://MYWEBSITE/mypath/italia');
        });
    </script>
  </body>
</html>

0 个答案:

没有答案