Disable zoom/pan when selecting point

4127
11
06-18-2010 09:04 AM
BradleyMontgomery
New Contributor II
This has probably been addressed somewhere but I wasn't able to find it. Anyway, I have a custom widget that allows a user to select a point and then pop up a bunch of data about the point from related tables. It all works great except that the map navigation tools are still enabled when the user is selecting the point. If the zoom tool had been previously selected, when the user clicks on the point they want, the map zooms in. If pan has been selected and the user just happens to hold down the mouse for a few milliseconds and moves it while selecting the point, the map pans. I've tried disabling the navigation toolbar as in:

var navToolbar:Navigation;
navToolbar = new Navigation();
navToolbar.map = map;
navToolbar.deactivate();

And then selecting the point as in:

setMapAction(Draw.MAPPOINT, status, drawEnd);

But the navigation tools are still active. How do I turn them off?

Thanks!
Tags (2)
11 Replies
DasaPaddock
Esri Regular Contributor
0 Kudos
BradleyMontgomery
New Contributor II
Here's what I added:

map.mapNavigationEnabled = false;
map.panEnabled = false;

Then select the point:

setMapAction(Draw.MAPPOINT, status, drawEnd);

Whatever zoom/pan tool that was previously selected is still active. The map still zooms or pans in addition to selecting the point.
0 Kudos
DasaPaddock
Esri Regular Contributor
What version of the API are you using?

Try activating the draw tool and then setting mapNavigationEnabled to false.
0 Kudos
BradleyMontgomery
New Contributor II
I'm using version 1.3. I put the setting of mapNavigationEnabled both after the setMapAction(Draw.MAPPOINT, status, drawEnd); statement and in the 'drawEnd' routine that gets called after a point is clicked. Neither worked.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Charlie,

   In your MapManager.mxml make sure your enableMapAction function looks like this:

//draw tool clicked
      private function enableMapAction(event:AppEvent):void
      {
       var data:Object = event.data;
       var tool:String = data.tool;
       var status:String = data.status;
       drawEndFunction = data.handler;
       navToolbar.deactivate();
       drawToolbar.activate(tool);
       map.panEnabled = false;
   map.mapNavigationEnabled = false;
   map.rubberbandZoomEnabled = false; 
       map.zoomSliderVisible = false;      
       SiteContainer.setStatus(status);  
      }
0 Kudos
BradleyMontgomery
New Contributor II
Thanks Robert. That function is in the MapManager.mxml. It looks like it should be turning off zooming and panning whenever the setMapAction() function is used but it's not. So far everything I've tried is not helping.
RobertScheitlin__GISP
MVP Emeritus
Charlie,

   Are you saying that you added the additional lines to the enableMapAction in your MapManager.mxml and it is still not working?
0 Kudos
BradleyMontgomery
New Contributor II
Those lines were already there. I put an Alert in the enableMapAction function just to make sure it was firing when I did a setMapAction. It is firing but is not disabling zooming and panning.

I did find a partial solution for the zooming part anyway. If I put in these lines:

map.removeEventListener(MouseEvent.CLICK,SiteContainer.reScaleMapIn);  
map.removeEventListener(MouseEvent.DOUBLE_CLICK,SiteContainer.reScaleMapIn);
map.removeEventListener(MouseEvent.CLICK,SiteContainer.reScaleMapOut); 
map.removeEventListener(MouseEvent.DOUBLE_CLICK,SiteContainer.reScaleMapOut);

The zooming is disabled. I still can't figure out how to disable panning.
BradleyMontgomery
New Contributor II
Just as an aside, I tested this in a an unmodified copy of the sample flexviewer. If  you select the Draw tool and select the point icon, when you draw a point, if you hold the mouse down and move it, it pans and does not draw a point. If you click fast enough and don't drag the mouse while you're clicking, it draws the point. I added code to set the map.panEnabled = false to the draw widget but it had no effect.

The problem is that if the user happens to hold the mouse down just a little too long when trying to select a point, the application pans and the user is left wondering what happened.
0 Kudos