Google Maps API not centering the Marker

后端 未结 2 1470
抹茶落季
抹茶落季 2021-01-19 12:28

I have Google Maps on a website that sets the marker based on an address.

Here\'s an example (click the location tab): http://www.weddinghouse.com.au/wedding-directo

相关标签:
2条回答
  • 2021-01-19 12:40

    If you load the page in google maps and then click on the "link" function, it gives you code to embed the site as an iFrame instead of messing about with the API- you could try this?

    There is also a bug with this that sometimes the marker is not centered, particularly on a hidden div. My best way to overcome this is to put the iFrame of the google map in a separate file (e.g. pages/map.html) and then to make that the source of the iFrame in your page.

    E.g.- instead of iFrame src="maps.google.com/ etc etc" have it as src="pages/map.html"

    Anyway, this post is 6 months old but better late than never!

    0 讨论(0)
  • 2021-01-19 12:42

    For me, the problem was the iframe having size 0 (display:hidden) when the map was loaded. I added a delay to load the map after the iframe was loaded. This race condition could explain why some of the addresses rendered correctly.

    Perhaps try this:

    <script type="text/javascript">
      $(document).ready(function(){
        setTimeout("delayedLoad()",100);
      });
      function delayedLoad() {
        load('Zoning In Personal Training', '27 Sitella Drive, berwick, VIC, 3806');
      }
    </script>
    

    (thanks to https://groups.google.com/forum/#!topic/google-maps-api/nN0y2pSr2dQ)

    0 讨论(0)
提交回复
热议问题