Select to view content in your preferred language

MapEvent Constant Field Values

1664
4
Jump to solution
12-02-2013 07:08 AM
CarlosColón-Maldonado
Frequent Contributor
Greetings,

While there appears to be no difference between APIs, this question refers to the 10.1.1 version. I notice that there are eight constant integer field variables contained in the MapEvent object as follows: MAPEVENT_FIRST, MAPEVENT_READY, MAPEVENT_EXTENT_CHANGED, MAPEVENT_ALLLAYERSREMOVED, MAPEVENT_PAN_ENDED, MAPEVENT_ZOOM_COMPLETED, MAPEXTENT_LAST, and MAPEVENT_DISPOSE.

I also notice that the getID() method is inherited from the AWTEvent super class, and that, while debugging, the MapEvent object does not appear to contain an integer, other than the inherited, that would identify the type of MapEvent it's suppose to be.

I'd like to know how can I determine what action was taken to change the extent of the map that would coincide with these values, if that's what they're suppose to be used for. I've tried the below code and all I get is MAPEVENT_EXTENT_CHANGED as the matching event, likely because the AWTEvent Id is not set with these values:

            @Override             public void mapExtentChanged(MapEvent event) {                 if (event.getID() == MapEvent.MAPEVENT_PAN_ENDED) {                     System.out.println("MAPEVENT_PAN_ENDED: " + event.getID());                 } else if (event.getID() == MapEvent.MAPEVENT_FIRST) {                     System.out.println("MAPEVENT_FIRST: " + event.getID());                 } else if (event.getID() == MapEvent.MAPEVENT_PAN_ENDED) {                     System.out.println("MAPEVENT_PAN_ENDED: " + event.getID());                 } else if (event.getID() == MapEvent.MAPEXTENT_LAST) {                     System.out.println("MAPEXTENT_LAST: " + event.getID());                 } else if (event.getID() == MapEvent.MAPEVENT_ZOOM_COMPLETED) {                     System.out.println("MAPEVENT_ZOOM_COMPLETED: " + event.getID());                 } else if (event.getID() == MapEvent.MAPEVENT_EXTENT_CHANGED) {                     System.out.println("MAPEVENT_EXTENT_CHANGED: " + event.getID());                 }             }


Best practices for this functionality would be very helpful and appreciated.

Thanks in advanced.
0 Kudos
1 Solution

Accepted Solutions
ColinAnderson1
Esri Contributor
Only MAPEVENT_READY, MAPEVENT_EXTENT_CHANGED and MAPEVENT_DISPOSE are used. The other values are no longer used. These three correspond to the MapEventListener interface mapReady, mapExtentChanged and mapDispose. Since you handle specific events through this interface the event IDs are not of much use e.g. if you handle mapExtentChanged then it would have the ID of MAPEVENT_EXTENT_CHANGED.

Hopefully the unused IDs can be removed in the next release.

View solution in original post

0 Kudos
4 Replies
ColinAnderson1
Esri Contributor
I believe that map ready and map extent changed are the only events that are used. There is no way to know what caused the map extent to be changed.
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
I believe that map ready and map extent changed are the only events that are used.


That's my observation as well, apart for the map disposing event which also uses this parameter. My real question is that, if not, then what are these constant fields values in the map event used for? Internal use only? Is this an "oops" because the Id of the event is suppose to match this enumeration (if so, let us know if you're fixing it)? They don't appear to be used elsewhere.
0 Kudos
ColinAnderson1
Esri Contributor
Only MAPEVENT_READY, MAPEVENT_EXTENT_CHANGED and MAPEVENT_DISPOSE are used. The other values are no longer used. These three correspond to the MapEventListener interface mapReady, mapExtentChanged and mapDispose. Since you handle specific events through this interface the event IDs are not of much use e.g. if you handle mapExtentChanged then it would have the ID of MAPEVENT_EXTENT_CHANGED.

Hopefully the unused IDs can be removed in the next release.
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
Only MAPEVENT_READY, MAPEVENT_EXTENT_CHANGED and MAPEVENT_DISPOSE are used. The other values are no longer used. These three correspond to the MapEventListener interface mapReady, mapExtentChanged and mapDispose. Since you handle specific events through this interface the event IDs are not of much use e.g. if you handle mapExtentChanged then it would have the ID of MAPEVENT_EXTENT_CHANGED.

Hopefully the unused IDs can be removed in the next release.


Thanks, Colin. You confirmed my suspicions.  I can see why they were removed given that a map extent event will always occur when either a pan or zoom is executed. Perhaps, it should be considered to implement these events instead of doing away with them in order to add more flexibility to the Map's API in terms of user manipulation/interaction by use of the listener's adapter.
0 Kudos