Dynamic google map with custom tiles prevent repeating pan

后端 未结 3 970
梦如初夏
梦如初夏 2021-02-09 19:47

I have a dynamic tile set where I do NOT want to allow panning outside of its bounds.

The below code gets me close, but the user can still scroll horizontally outside of

3条回答
  •  时光说笑
    2021-02-09 20:21

    Instead of using map.getCenter() as a check, use map.getBounds()

    Untested, but a simple way to accomplish this would be to check if the union of both bounds were identical (if not, your map bounds is outside your strict bounds):

    var union = strictBounds.union(map.getBounds());
    if (strictBounds.equals(union)) { //new map bounds is within strict bounds
    

提交回复
热议问题