Is it possible to make a custom pan/zoom function without using the dijit Bookmarks widgets?

781
4
09-01-2016 12:25 PM
JohnAdams
New Contributor III

I am trying to make some custom bookmarks that just involve html buttons and manipulating the map object. I don't want to use the digit Bookmarks widgets. The various pan methods in the Javascript API (panRight, panLeft, panUp, etc) are sort-of what I want, but you cannot specify exactly where to go. I've also tried using the centerAt(evt.mapPoint) method, which is also sort-of what I want, however, I'm having difficulty calling the centerAt method outside of the require function (which is what I need to do for my dijit-free bookmarks). If I put it outside the require function it doesn't work, and if I try to put it in a function inside the require function, the map does not draw. What I would like to do is something like this:

map.pan(x-coored, y-coord);

Hope that made sense.

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

John,

   You should be able to do this and have it inside the require. Can you share your code attempt?

0 Kudos
JohnAdams
New Contributor III

No, I cannot do it in the require function, all attempts to place it inside the require function end up making the map not draw when the page starts up. I'll share the relevant parts of my code:

Here is the code. Ignore the sidebar stuff. There is some stuff commented-out for the time being, and for testing.

----------------------------------

...nevermind ...

0 Kudos
JohnAdams
New Contributor III

BTW, the stuff in the "navigate" function is the main part I'm having problems with. I cannot put that function inside the require function, because the map does not draw if I do. I can create Point objects inside the require function just fine, but I cannot access them from inside the navigate function (which is frustrating, because I can access the map object and some other objects from in there). I also cannot seem to create Point objects from inside the navigate function either.

0 Kudos
JohnAdams
New Contributor III

Wait ... I think I got it. If I declare my Point object outside the require function I can access it in my navigate function. Duh.