Select to view content in your preferred language

Coordinate Menu Widget - New !

21447
95
02-17-2011 07:51 PM
Drew
by
Frequent Contributor
Hello Everyone,
I created a new widget that you might find useful.
Tucked away in the map context menu are three XY operations

   1.     Copy XY
   2.     Project XY (configurable)
   3.     Go To XY

ReadMe.txt included

Hope you find it useful!

Click Here to demo and download the Coordinate Menu Widget

Drew
Tags (2)
0 Kudos
95 Replies
JeffersonFerreira_Ferreira
Deactivated User
This has been discussed in the thread, see above. Draw corrected the source code, either download the zip file again or follow rzufelt's correction to fixed the typo in the source.


Dear Hakim;

I have already solved this issue following the rzufelt instructions and correting the mxml. But I still having problems with the Live Coordinates format. To this WEBGIS application's users the WebMercator metric coordinates it's quite confuse. So I want to show them in WGS84 DD.DDD or DMS format. If someone can give me a direction on this, will be great.

Thanks for your attention, Hakim.
Hugs for all
0 Kudos
RhettZufelt
MVP Notable Contributor
Hi Drew,

I see you added the DMS option for output.  Was wondering if there is a coordinate system tag for the xml to accept DMS as input?

  <coordinateSystem name="GCS WGS 1984 (Decimal Degrees)"
   wkid="4326" decimals="9" />


I want the same system as above, just would prefer to be able to enter in the DMS as well (otherwise, I always have to convert to DDD first.  easy for me, but the "users" have a fit ) 😉

Thanks again,

R_
0 Kudos
JeffersonFerreira_Ferreira
Deactivated User
Hi all;

Another little question about coordinate format with this widget. For my coordinates were shown in "live coordinates" in decimal degrees, I had to change the order of my basemaps, placing firstly my image service to the entire map image acquired its spatial reference system (GCS_WGS84). But when that is done, the function "go to"no longer work and there is a warning "Error projecting coordinates".

Maybe that widget does not work in another spatial reference system that is not webmercator? Any ideas?
Thanks!
0 Kudos
MegPeterson
Regular Contributor
Brilliant! Drew thank you so much.

Two quick questions (hopefully):

1. Is there a way to have the "Go to Coordinates" window preload when the application starts instead of 'Live Coordinates'? Can I just copy the widget and comment out everything but the 'Go to Coordinates' functionality?

2. Is there a way for users to enter DMS and DM (in addition to Decimal Degrees) in the custom drop down? Our clients aren't used to converting DMS/DM to DD.

Many thanks, again!
0 Kudos
RhettZufelt
MVP Notable Contributor
Brilliant! Drew thank you so much. 

Two quick questions (hopefully): 

1. Is there a way to have the "Go to Coordinates" window preload when the application starts instead of 'Live Coordinates'? Can I just copy the widget and comment out everything but the 'Go to Coordinates' functionality? 

Many thanks, again!


Well, there is probably a "better" way to do this, but this works:

Make this change:

<viewer:WidgetTemplate open="{this.graphicsLayer.visible = true; }" closed="{this.graphicsLayer.visible = false; }" id="wTemplate" width="400" height="235" visible="false">


and add this:

   private function init():void
   {
    //Set Helper
    this.helper = new CoordinateMenuWidgetHelper(configXML,map);
    
    //SET Mouse Event Handlers
    this.map.addEventListener(MouseEvent.MOUSE_MOVE, onMapMouseMove);
    this.map.addEventListener(MouseEvent.CLICK, onMapMouseClick);
    
    //Add GraphicsLayer to map
    this.graphicsLayer.symbol =  new SimpleMarkerSymbol("circle",10,0xFF0000);;
    this.map.addLayer(this.graphicsLayer);
    
    // add additional contex menu for projected coords.
    if (this.helper.coordinateSystems.length == 0)
    {
     btnProject.visible = false;
     btnProject.includeInLayout = false;
    }
    goToCoordinate.show(configXML,map);   
   }
   
0 Kudos
HakimAbdi
Occasional Contributor
Hi Drew,

I've got a bit of a predicament. I'm using a base map of the Antarctic in the Universal Polar Stereographic South projection (wkid="32761"), is there a way to show the "Selected Coordinates" box in decimal degrees (lat/long) instead of meters? I don't mind the "Live Coordinates" being in meters.

Thanks!

Cheer,
Hakim
0 Kudos
MegPeterson
Regular Contributor
Rhett - Perfect! Now just trying to figure out DMS and DM for input.

Thank you!
0 Kudos
MegPeterson
Regular Contributor
Hi Rhett -

I've been plugging along to get the 'Go to XY' widget working as a standalone. I'm slowly learning as I go, but running into a small issue.

Once I launch the "widget" and then close it, the widget 1. doesn't lose focus in the widget panel (ie: the white underline is still below the icon), and 2. it won't re-open. See the on close attachment.

Do you know of a quick function/command/something-er-rather to add to the s:TitleWindow to get it to reset? It only resets if I re-launch the applicaiton.

Many thanks, Meg
0 Kudos
JeffersonFerreira_Ferreira
Deactivated User
It's weird... If someone can give any idea...
I had to change the order of my basemaps, placing firstly my image service. This makes my whole map at GCS_WGS84. But when thatis done the function "go to"no longer work and there is a warning "Error projecting coordinates".

This widget (GoTo) only work if the map is in webmercator? Any ideas?
Thanks!
0 Kudos
RhettZufelt
MVP Notable Contributor
Hi Rhett -  

I've been plugging along to get the 'Go to XY' widget working as a standalone. I'm slowly learning as I go, but running into a small issue. 

Once I launch the "widget" and then close it, the widget 1. doesn't lose focus in the widget panel (ie: the white underline is still below the icon), and 2. it won't re-open. See the on close attachment. 

Do you know of a quick function/command/something-er-rather to add to the s:TitleWindow to get it to reset? It only resets if I re-launch the applicaiton. 

Many thanks, Meg


Meg,

I'm pretty new to the Flex stuff myself, and not sure how to handle this. I tried adding a widgetClosedHandler function, but since it is pulled in by the widget, and not actually the widget, I could not figure out how to have the helper close/minimize the widget it is fired from (visible or not).

However, I found a different option that might work for you. I removed CoordinateMenuWidget_GUI from the widgetcontainer in my config xml. I then added the CoordinateMenuWidget to the UI elements section in the config.xml.

That way, any time you want to get a coordinate, or GoTo a coordinate, you just use the right-click mouse menu.

If you want the GoTo dialog to open when the map starts so that it is visible (also modified the GoToCoordinateDialog title to inform user about right click to re-open), can make this change to the CoordinateMenuWidget .mxml:

   protected function widgetConfigLoadedHandler(event:Event):void
   {
    if (configXML)
    {
     //Set Helper 
     this.helper = new CoordinateMenuWidgetHelper(configXML,map);

     // Map mouse move event handler - captures XY
     this.map.addEventListener(MouseEvent.MOUSE_MOVE, onMapMouseMove); 
     
     //Hide ESRI About Menu Items
     hideESRIMenuItems();
     
     // Load context Menu items.
     createContextMenu(); 
    }
    else
    {
     //Show error if XML fails.
     Alert.show("There was an error loading the widget configuration XML file ( CopyXY Widget )");
     return;
    }
\\My Add    this.goToCoordinates.show(configXML,this.map);
   }


Maybe someone that actually knows what they are doing will chime in and help,

R_
0 Kudos