Google Maps API V3 fitbounds() zooms out but never in

前端 未结 12 2373
感动是毒
感动是毒 2020-12-19 03:44

I\'ve created a quite complex store locator of sorts. The user enters their zip and a table returns results with corresponding markers on a map. They can page through result

12条回答
  •  有刺的猬
    2020-12-19 04:06

    Make sure there are no CSS animations on the width or height of your map. The animations interfere with the zoom behaviour of fitBound()

    I spent most of the day on this problem yesterday, and I encountered this StackOverflow post at least a dozen times. But I eventually had to find the problem the hard way on my own.

    Deleting the transition: all 0.5s ease; line below fixed it for me.

    .google-map {
      width: 100%;
      height: 0px;
      transition: all 0.5s ease;
    }
    
    .google-map.loaded {
        height: 400px;
    }
    
    

提交回复
热议问题