Select to view content in your preferred language

Right click functionality in Flex viewer 2.5

3030
10
Jump to solution
05-02-2012 04:16 PM
DanielOchoa
Regular Contributor
All,

In Robert Scheitlin's Calhoun County Parcel Viewer, users have the ability to right click and engage a couple of functions:

[ATTACH=CONFIG]14036[/ATTACH]

...specifically, "Copy coordinates to clipboard" and "export map extent"

I've seen similar functionality in a Silverlight viewer:

[ATTACH=CONFIG]14037[/ATTACH]

...where a user can do even more. I'd like to try to impliment this type of right-click functionality into my viewer - but I'm not sure where to begin.  I know that there are widgets that can perfom these functions, but I'm thinking these tools are there as a result of modifying the base code (mxml) of the viewer itself. Or am I wrong and these are just modified widgets themselves?  I know of the coordinate widget, and it works really well, but I'd like to give a simple right-click option a try. Thats my first question....second would be more of a request - if anyone can give me some advice or code to impliment in my Flex viewer regarding this functionality, even if its for only one type of function, I could go from there.  Finally, does anyone who has used the 3.0 prerelease know if there is there any of this right-click functionality present/available?

Any help is, as always, highly appreciated.  And Rob if you wind up reading this thread, thanks for all the great products and help in the past.

~ D
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanielOchoa
Regular Contributor
That worked!

Everything is looking good - the only other problem I ran into with your code was this line

[ATTACH=CONFIG]14069[/ATTACH]

...but as before, if I comment this out, everything works.  Just curious as to why this error occurs.

And finally, when displaying and capturing the coordinates, I'm getting dd with 14 digits to the right of the decimal point, like this:  Lat: 32.56756965588102 Lon: -116.94610602294371

Is there a quick and easy way to get less, say 5 digits?

Otherwise, this all worked brilliantly.  I'll now try to learn more code and impliment the other functions I mentioned in my first post.

Thanks!

~ D

View solution in original post

0 Kudos
10 Replies
RobertScheitlin__GISP
MVP Emeritus
Daniel,

   Hopefully I don't forget anything... Here is the additions to the MapManager.mxml, WidgetManager.mxml and HeaderControllerWidget.mxml. Make sure you comment all your changes so that when Flex Viewer 3.0 comes out in a couple of months you can easily find the code additions.

Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:
0 Kudos
omega_cancer
Frequent Contributor
Yes, Rob your help is tremendous.
0 Kudos
DanielOchoa
Regular Contributor
Daniel,

   Hopefully I don't forget anything... Here is the additions to the MapManager.mxml, WidgetManager.mxml and HeaderControllerWidget.mxml. Make sure you comment all your changes so that when Flex Viewer 3.0 comes out in a couple of months you can easily find the code additions.

Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:



Robert,

Thanks for your attention to my question.  I swear, more than half of us would be dead in the water without you.

Two things. As you will see in the attached graphic, I'm getting errors with three lines of your changed code (addMapListeners) in the MapManager.mxml: 

[ATTACH=CONFIG]14064[/ATTACH]

The errors are "1120: Access of Undefined property" -  4 times for each line (maploadComplete, mapMouseDown, mapMouseUp)

However, after removing the three lines and running the index, the viewer loads and the the tools seem to work fine....but I know from past experience this may not mean anything....any thoughts?

The only other thing is that I would like to display (in the header) and capture (in the right clip copy to clipboard) the coordinates in decimal degrees instead of DMS.  Do you happen to have the code handy for that?

Again, thanks!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Daniel,

   It is safe to remove those as I forgot an left them in by accident.

I have not tested this but getting decimal degrees should be as simple as this change:

            private function mouseMoveHandler(event:MouseEvent):void
            {
                const mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
                const geoPnt:MapPoint = WebMercatorUtil.webMercatorToGeographic(mapPoint) as MapPoint;
                mapX = geoPnt.x; //geoMapPnt2dmsString(geoPnt,"x");
                mapY = geoPnt.y; //geoMapPnt2dmsString(geoPnt,"y");
                mapXY = "Lat: " + mapY + " Lon: " + mapX;
            }
0 Kudos
DanielOchoa
Regular Contributor
Robert,

Here's what I got.

[ATTACH=CONFIG]14065[/ATTACH]

...so, not working yet.

Will this also change how the coordinates are captured in the right-click function? If for some reason displaying the coordinates in DD in the banner cant happen, thats ok.  Its the right-click copy to clipboard function I'm most concerned with.

Thanks,

~ D
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Daniel,

   The right click capability uses the coordinates displayed in the banner.

Try this then:

mapX = geoPnt.x.toString(); //geoMapPnt2dmsString(geoPnt,"x");
mapY = geoPnt.y.toString(); //geoMapPnt2dmsString(geoPnt,"y");
0 Kudos
DanielOchoa
Regular Contributor
That worked!

Everything is looking good - the only other problem I ran into with your code was this line

[ATTACH=CONFIG]14069[/ATTACH]

...but as before, if I comment this out, everything works.  Just curious as to why this error occurs.

And finally, when displaying and capturing the coordinates, I'm getting dd with 14 digits to the right of the decimal point, like this:  Lat: 32.56756965588102 Lon: -116.94610602294371

Is there a quick and easy way to get less, say 5 digits?

Otherwise, this all worked brilliantly.  I'll now try to learn more code and impliment the other functions I mentioned in my first post.

Thanks!

~ D
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Daniel,

   Commenting it out or deleting it is fine as once again I use that for something else that does not pertain to this.

As far as the number of decimal places that is as simple as:

mapX = geoPnt.x.toFixed(5);



So now it is your turn.

Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Daniel,

  Don't forget Step 1 in this graphic. It is how I receive points for answering your question and how others know that this thread has been answered:

0 Kudos