fitBounds doesn't work sometimes
mapbox-gl-js version:1.13.1
Question
hello,I use addLayer to show some polygons,when change the polygon data,I want to use fitBounds to get better view,most time,it worked well,but sometimes,some area is out of bounds,I don't know why.Am i doing something wrong, or is there a bug in fitbounds?Here is my code: this.map = new mapboxgl.Map( { container:'map', style:...some style, zoom:6, pitch:60, bearing:0, center:[113.45,34,81], hash :false, renderWorldCopies:false } )
when change the data,I use fitBounds, here is the code let bbox = turf.bbox(mapData) this.map.fitBounds([[bbox[0],bbox[1]],[bbox[2],bbox[3]]])
looking forward to your reply,thank you.
Unfortunately there's no way to diagnose an issue like this without a reproducible live test case — bits of quoted code aren't enough, it could be any number of things. Please provide one for us to be able to help you, using JSFiddle or a similar tool.
Unfortunately there's no way to diagnose an issue like this without a reproducible live test case — bits of quoted code aren't enough, it could be any number of things. Please provide one for us to be able to help you, using JSFiddle or a similar tool.
thanks for your reply,I can't visit JSFiddle,I use the CodePen,this is the link,https://codepen.io/skyzhen/pen/vYRQQod?editors=1010,when you click btn 'test1',it works well;but when click 'test2' to change data,some area will out of the bound
邮件已收到,谢谢!