Google Maps V3 fitBounds on visible markers

后端 未结 3 1335
深忆病人
深忆病人 2021-02-10 23:07

Finding it hard to get clear information on this but what I am trying to achieve is fitBounds on visible markers.

The Array defines the title, category, lat/long and hre

3条回答
  •  有刺的猬
    2021-02-11 00:00

    well, you could program that inside your show function, I created own fiddle for you which demonstrates how to set 2 markers visible from array of 3 markers and fitBounds for only those:

    fiddle example

    Since code is now visible, with your case you could make separate fitBoundsToVisibleMarkers() method to be runned always after show() and hide() methods. for example:

    function fitBoundsToVisibleMarkers() {
    
        var bounds = new google.maps.LatLngBounds();
    
        for (var i=0; i

    and your code does this:

    function show(category) {
        for (var i=0; i

提交回复
热议问题