简体   繁体   English

Google Maps API v3未加载所有标记

[英]Google Maps API v3 not loading all markers

I've had a look around, but no one seems to have a similar problem. 我环顾四周,但似乎没有人遇到类似的问题。

I'm trying to create a map that has 5 markers for 5 locations, but for some reason, the map only seems to be loading 4 我正在尝试创建一个具有5个标记的5个位置的地图,但是由于某种原因,该地图似乎只加载了4个

Here's a link to my code http://urloritdidnthappen.appspot.com/501001 这是我的代码的链接http://urloritdidnthappen.appspot.com/501001

So what have I tried? 那我尝试了什么?

I had the thought that two of these markers were too close together. 我以为这些标记中的两个太靠近了。 The one not showing (croEndMarker) was very close in location to hornsMarker. 一个未显示的(croEndMarker)与hornsMarker的位置非常接近。 I removed hornsMarker, but to no avail. 我删除了hornsMarker,但无济于事。

Then, I swapped the co-ordinates of croEndMarker with those of hornsMarker. 然后,我将croEndMarker的坐标与hornsMarker的坐标交换。 hornsMarker was then showing in the position of croEndMarker. hornsMarker随后显示在croEndMarker的位置。 Not sure what I was trying to rule out here, but suffice to say there is no black hole swallowing markers in that exact location 不知道我要在这里排除什么,但足以说在该确切位置没有黑洞吞咽标记

I really don't know what my next step should be. 我真的不知道下一步该怎么做。 Is there a limitation to the amount of markers you can place in a specific area? 您可以在特定区域放置的标记数量是否有限制?

Thank you all very much for any help you can offer 非常感谢您提供的任何帮助

TL;DR: Map won't show all 5 markers, please help. TL; DR:地图不会显示所有5个标记,请提供帮助。 http://urloritdidnthappen.appspot.com/501001 http://urloritdidnthappen.appspot.com/501001

As requested, the code itself: 根据要求,代码本身:

      <script type="text/javascript">
        function initialize() {

          var brentX = new google.maps.LatLng(51.575363, -0.225273);
          var finCen = new google.maps.LatLng(51.60096, -0.192459);
          var horns = new google.maps.LatLng(51.58713,-0.121549);
          var finPar = new google.maps.LatLng(51.568574, -0.102657);
          var croEnd = new google.maps.LatLng(51.579656,-0.153775);

          var mapOptions = {
            center: new google.maps.LatLng(51.542492, -0.103394),
            zoom: 12,
            mapTypeId: google.maps.MapTypeId.ROADMAP
          };
          var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);

          var brentXMarker = new google.maps.Marker({
            position: brentX,
            title: "Brent Cross"
          });

          var finCenMarker = new google.maps.Marker({
            position: finCen,
            title: "Finchley Central"
          });

          var hornsMarker = new google.maps.Marker({
            position: horns,
            title: "Hornsey"
          });

          var finParMarker = new google.maps.Marker({
            position: finPar,
            title: "Finsbury Park"
          });

          var croEndMarker = new google.maps.Marker({
            position: croEnd,
            title: "Crouch End"
          });


        brentXMarker.setMap(map);
        finCenMarker.setMap(map);
        hornsMarker.setMap(map);
        finParMarker.setMap(map);
        croEndMarker.setmap(map);

        }
        google.maps.event.addDomListener(window, 'load', initialize);
      </script>

  <div id="map-canvas" style="width: 1200px; height: 600px;" />

Watch your camelcase . 看着你的camelcase It should be: 它应该是:

croEndMarker.setMap(map);

FWIW, this would have appeared in the console log as: FWIW,这将在console log为:

TypeError: croEndMarker.setmap is not a function

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM