stamen / modestmaps-js

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

Easey and setExtent #139

Closed kinski76 closed 12 years ago

kinski76 commented 12 years ago

Hi

Wondered if someone could help clarify something...

Is it possible to use easey and tween to an extent?

I am currently using:

MM_map.setExtent(locations);

Which work great but it would be awesome If I could use easy to animate to the extent. Can't work out if it's currently possible so any help would be appreciated.

thanks very much in advance

ade

shawnbot commented 12 years ago

Hi Ade,

To ease to an extent you'll need to modify the map first, then grab its coordinate and pass that to easey. This is untested, but it's a pattern that I've used before:

// assuming you have a MM.Map instance named map
var ease = easey().map(map);
// get a copy of the current center coordinate
var currentCoord = map.coordinate.copy();
// set the extent, changing the center coord
map.setExtent(locations);
// grab a copy of the new coordinate
var nextCoord = map.coordinate.copy();
// return the map to its previous state
map.coordinate = currentCoord;
// ease to the new extent coord
ease.to(nextCoord)
  .run(1000);

Does that work?

kinski76 commented 12 years ago

Shawn

You are a god send that works! :)

Thank you very much

ade

On 12 Jul 2012, at 19:50, Shawn Allen wrote:

Hi Ade,

To ease to an extent you'll need to modify the map first, then grab its coordinate and pass that to easey. This is untested, but it's a pattern that I've used before:

// assuming you have a MM.Map instance named map
var ease = easey().map(map);
// get a copy of the current center coordinate
var currentCoord = map.coordinate.copy();
// set the extent, changing the center coord
map.setExtent(locations);
// grab a copy of the new coordinate
var nextCoord = map.coordinate.copy();
// return the map to its previous state
map.coordinate = currentCoord;
// ease to the new extent coord
ease.to(nextCoord)
 .run(1000);

Does that work?


Reply to this email directly or view it on GitHub: https://github.com/stamen/modestmaps-js/issues/139#issuecomment-6944100

shawnbot commented 12 years ago

Glad to be of service!

kinski76 commented 12 years ago

oooo one other little question if you don't mind:)

.path("about") is so much for what I'm trying to do. However using this plays a bit of havoc with the bounding box set with extent. So currently when I zoom in using .path("about") some of the content that "should" appear based on the extent set gets lost. Is there a way around this or is it a case of sticking to .path("screen")?

cheers once more:|

ade

On 12 Jul 2012, at 20:07, Shawn Allen wrote:

Glad to be of service!


Reply to this email directly or view it on GitHub: https://github.com/stamen/modestmaps-js/issues/139#issuecomment-6944589

shawnbot commented 12 years ago

To be totally honest, I'm not sure. Paging @tmcw :)