Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map.fitBounds doesnt work anymore after drawing a polygon #437

Closed
Ghistos opened this issue Jun 29, 2016 · 6 comments
Closed

map.fitBounds doesnt work anymore after drawing a polygon #437

Ghistos opened this issue Jun 29, 2016 · 6 comments
Milestone

Comments

@Ghistos
Copy link

Ghistos commented Jun 29, 2016

After I have drawn a polygon on my map, if I call map.fitBounds([[x,y], [x,y]], options) it doesnt work.
If I draw only a point, the map.fitBounds still working.

@mcwhittemore mcwhittemore added this to the 1.0.0 milestone Jun 30, 2016
@mcwhittemore
Copy link
Contributor

@Ghistos this seems to be working for me in v0.11.9. What version are you using?

@Ghistos
Copy link
Author

Ghistos commented Jul 13, 2016

I was using the version .10 when I tested

@Ghistos
Copy link
Author

Ghistos commented Jul 19, 2016

Well, I just installed the v0.11.10 and I still can't use the fitBounds after drawing a polygon. Only a point.

I tried it with a simple test. When I double click on the map before using draw, each time the fitBounds goes at the right place but as soon as I draw a polygon, the fitBounds doesnt work anymore.

var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9'
});
var Draw = mapboxgl.Draw();
map.on('style.load', function () {
map.on('dblclick', mouseDblClick);
map.addControl(Draw);
});
function mouseDblClick(e) {
var options = {
"maxZoom": 8,
"linear": false,
bearing: 0,
speed: 8,
curve: 2,
easing: function (t) {
return t;
}
};
map.fitBounds([[-72.996822, 45.589321], [-71.372368, 46.571981]], options);

}

@mcwhittemore
Copy link
Contributor

@Ghistos I was able to produce this both in Draw and in mapbox-gl-js. I've created a jsbin showing the problem in mapbox-gl-js and I have opened the upstream ticket. You can follow it here.

mapbox/mapbox-gl-js#2891

@Ghistos
Copy link
Author

Ghistos commented Jul 19, 2016

Tks for the update

@mcwhittemore
Copy link
Contributor

mcwhittemore commented Sep 16, 2016

@Ghistos - sorry for the long delay. The problem here is that your handler is running before the doubleClickZoom handler. If you don't want doubleClickZoom to ever run you should disable it at the start of your handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants