Select to view content in your preferred language

An issue when I click on the zoom button of my widget

1728
6
Jump to solution
06-15-2012 08:34 AM
AlaeddineSaadaoui
Regular Contributor
Hi all,
I have an issue with the zoom button of my widget. When I click on the button, the widget goes a little bit far from my point. I am using the following code for zooming:
var here:MapPoint = map.toMap(new Point(map.infoWindow.anchorX, map.infoWindow.anchorY));
if (map.scale > zoomScale)
map.scale = zoomScale;
map.centerAt(here);
I would like to know how I could fix this problem.
Thank you for your help.
0 Kudos
1 Solution

Accepted Solutions
AlaeddineSaadaoui
Regular Contributor
Sorry for the bad code. Maybe the quickest way to test my idea is to center your map first and then to scale. This will cause the event to fire after the map is manipulated.

As for the type error, I was wrong about the arguments needed for the extent change event. I would investigate the api at http://help.arcgis.com/en/webapi/flex/apiref/index.html

Hi ploebus,
I used the code zoomToButton_clickHandler found in the PopUpRenderSkin.mxml and it worked.
Thank you very much for your help.

View solution in original post

0 Kudos
6 Replies
by Anonymous User
Not applicable
Original User: ploebus

In the older viewer, the infoPopup listens for the extent event and changes its location accordingly. When you set the map scale to the zoom scale, this fires the extent event, but than you further manipulate the map by setting its center which does not fire the event. Maybe this is why the infowindow is offset from the point?
0 Kudos
AlaeddineSaadaoui
Regular Contributor
In the older viewer, the infoPopup listens for the extent event and changes its location accordingly. When you set the map scale to the zoom scale, this fires the extent event, but than you further manipulate the map by setting its center which does not fire the event. Maybe this is why the infowindow is offset from the point?

Hi ploebus,
In this case, how could I change my code to fix this issue?
Thank you very much for your help.
0 Kudos
by Anonymous User
Not applicable
Original User: ploebus

If this is the cause, I think you could center the map first and then zoom to new extent

or

you could manually dispatch the ExtentEvent.EXTENT_CHANGE to force infopopup to change location.

map.dispatchEvent(new ExtentEvent(ExtentEvent.EXTENT_CHANGE));


-
0 Kudos
AlaeddineSaadaoui
Regular Contributor
If this is the cause, I think you could center the map first and then zoom to new extent

or

you could manually dispatch the ExtentEvent.EXTENT_CHANGE to force infopopup to change location.

map.dispatchEvent(new ExtentEvent(ExtentEvent.EXTENT_CHANGE));


-

Hi ploebus,
I have change my code to look like the following:
protected function zoom_clickHandler(event:MouseEvent):void
   {
    var here:MapPoint = map.toMap(new Point(map.infoWindow.anchorX, map.infoWindow.anchorY));
    if (map.scale > zoomScale)
     map.scale = zoomScale;
    {
    map.centerAt(here);
    map.dispatchEvent(new ExtentEvent(ExtentEvent.EXTENT_CHANGE));
    }
   }
But I got this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.esri.ags.tools::NavigationTool/extentChangeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at widgets::StructureInfoWidget/zoom_clickHandler()
at widgets::StructureInfoWidget/__buttons_zoomToBtnClicked()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at widgets::AttRelateInfoButtons/zoomToBtn_Click()
at widgets::AttRelateInfoButtons/__zoomToBtn_click()
Thank you.
0 Kudos
by Anonymous User
Not applicable
Original User: ploebus

Sorry for the bad code. Maybe the quickest way to test my idea is to center your map first and then to scale. This will cause the event to fire after the map is manipulated.

As for the type error, I was wrong about the arguments needed for the extent change event. I would investigate the api at http://help.arcgis.com/en/webapi/flex/apiref/index.html
0 Kudos
AlaeddineSaadaoui
Regular Contributor
Sorry for the bad code. Maybe the quickest way to test my idea is to center your map first and then to scale. This will cause the event to fire after the map is manipulated.

As for the type error, I was wrong about the arguments needed for the extent change event. I would investigate the api at http://help.arcgis.com/en/webapi/flex/apiref/index.html

Hi ploebus,
I used the code zoomToButton_clickHandler found in the PopUpRenderSkin.mxml and it worked.
Thank you very much for your help.
0 Kudos