stamen / modestmaps-js

Modest Maps javascript port
http://modestmaps.com
566 stars 152 forks source link

map.setCenter ignores latitude #135

Closed manelclos closed 11 years ago

manelclos commented 12 years ago

Version 1.0.0-alpha3 works correctly, version beta1 ignores latitude. Using setExtent() and setZoom() works as a workaround

tmcw commented 12 years ago

Can you test with more current version of Modest Maps, like 2.0.0?

manelclos commented 12 years ago

Fails with 2.0.0 too. The code is from http://modestmaps.com/index.html

var template = 'http://c.tiles.mapbox.com/v3/mapbox.mapbox-light/{Z}/{X}/{Y}.png'; var provider = new MM.TemplatedLayer(template); var map = new MM.Map('map', provider); map.setCenter({ lat: 42.51, lon: 2.68 }).setZoom(9);

tmcw commented 12 years ago

Ah, that problem. Call setZoom before setCenter; setCenter corrects for zooms that go out of the map's bounds. The example on the site needs an update.

manelclos commented 12 years ago

Yes that worked. Anyway, can't MM remember the center so that it is taken into account when setZoom() is called? IMHO you shouldn't need to know how it works, it should just work.

Thanks!

tmcw commented 12 years ago

Yes, been thinking about this issue; I don't think modestmaps should remember the center (and thus decouple the 'real center' and the 'intended center') but setCenter might not want to, by default, bound the values - the user should need to select 'restrictions' on the map.

springmeyer commented 11 years ago

/cc @springmeyer - no bright ideas on a solution here, but I was following the mapbox.js examples for workshop prep and hit, so keen on it working more intuitively.

tmcw commented 11 years ago

Fixed in the main modestmaps repo: f09f9605ebff123b5860bab682fae4f7572d949f