3

I have a map that I'm initializing off-screen and sliding in using jQuery. For some reason zooming in with the scroll wheel or by double-clicking causes the map to simultaneously pan down (or pan up when zooming out). Using the slider controls works fine. Also if I disable the animation and create it on-screen it zooms normally. I'm guessing it has something to do with the relative position of the map to where it was created, but I don't imagine I have much control over that. Does anyone have any thoughts on this?

Here's how I'm styling the map:

#map { bottom: -450px; height: 450px; position: fixed; width: 100%; }

And this is my animation function:

toggleMap: function() {
    // New bottom value
    var newBottom;

    if (isShowing) {
        newBottom = -450px;
    }
    else {
        newBottom = 0;
    }

    isShowing = !isShowing;
    $map.animate({
        bottom: newBottom
    });
},
3
  • I've had the same issue with using dojo.fx to move the map in from the right or left. The map pans right or left as I zoom in and out with the scroll wheel.
    – raykendo
    Sep 19, 2013 at 3:09
  • Interesting... sounds like an under-the-hood problem with the API to me. Like its calculating the cursor position based on the starting point of the map. Anybody from Esri listening? :)
    – serverpunk
    Sep 19, 2013 at 15:30
  • If you post a full repro case I can take a look (I work on the JS API team at esri). One thing to make sure you're doing is calling map.reposition after you move the map's div: developers.arcgis.com/en/javascript/jsapi/… Sep 19, 2013 at 18:52

1 Answer 1

2

After you move the map's element (probably a div), call map.reposition().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.