How to select and copy specific text from Infowindow to clipboard

848
4
08-31-2011 08:09 AM
ShravanBonagiri
New Contributor
Hi All,

I would like to select specific text from the Infowindow and copy it to clipboard. Right now I am able to copy entire window. But my requirement is to select specific string and copy it to clipboard. Any help would be appreciated.
Here is my code:
private function onMapClick(event:MapMouseEvent):void
   {
    var latlong:MapPoint = WebMercatorUtil.webMercatorToGeographic(event.mapPoint) as MapPoint;   
    myMap.infoWindow.label = "Lat/Long: " + latlong.y.toFixed(6) + "/ " + latlong.x.toFixed(6);
    myMap.infoWindow.show(event.mapPoint);
    System.setClipboard(myMap.infoWindow.label);
   }

Thanks,
Sam
Tags (2)
0 Kudos
4 Replies
ShravanBonagiri
New Contributor
I am still looking for help with this problem. Have you guys had any work around solution for it.

Hi All,

I would like to select specific text from the Infowindow and copy it to clipboard. Right now I am able to copy entire window. But my requirement is to select specific string and copy it to clipboard. Any help would be appreciated.
Here is my code:
private function onMapClick(event:MapMouseEvent):void
   {
    var latlong:MapPoint = WebMercatorUtil.webMercatorToGeographic(event.mapPoint) as MapPoint;   
    myMap.infoWindow.label = "Lat/Long: " + latlong.y.toFixed(6) + "/ " + latlong.x.toFixed(6);
    myMap.infoWindow.show(event.mapPoint);
    System.setClipboard(myMap.infoWindow.label);
   }

Thanks,
Sam
0 Kudos
YungKaiChin
Occasional Contributor
What is the specific string that you want to copy to your clipboard? The Lat and Long value?
0 Kudos
ShravanBonagiri
New Contributor
What is the specific string that you want to copy to your clipboard? The Lat and Long value?


Yes! I want to copy Lat value separately and Long value separately, if possible.
0 Kudos
YungKaiChin
Occasional Contributor
Since you already have two values, you can simply use them and format the string to whatever you want.

For example:
System.setClipboard(latlong.y.toFixed(6).toString() + "\n" + latlong.x.toFixed(6).toString());

However, notepad does not support regular expressions, so you will have to paste it into a word doc.
0 Kudos