Select to view content in your preferred language

How do you get a MapPoint from a MultiPoint on MouseEvent?

596
3
05-05-2010 11:53 AM
EricTerpstra
New Contributor
If I click a specific MapPoint (represented by a SimpleGraphicSymbol) within a MultiPoint, how can i retrieve the information for only the point that was clicked.  Here's the code displaying the MultiPoint:

  <esri:GraphicsLayer id="glDeviceLayer"
   symbol="{deviceMarker}">

   <esri:Graphic id="glDevicePoints"
    click="pointClick(event)">

    <esri:geometry>

     <esri:Multipoint id="multipoint"
      points="{mapPoints}" />
    </esri:geometry>
   </esri:Graphic>

  </esri:GraphicsLayer>
Tags (2)
0 Kudos
3 Replies
ZahidChaudhry
Deactivated User
Heres something you can do in actionscript

private function onMouseClick(event:mouseEvent):void{

var mygraphic:Graphic = event.currentTarget as Graphic;
if (mygraphic){
var myMapPoint:Mappoint = Mappoint (mygraphic.geometry);

var lat:number = myMapPoint.y;
var lon:number = myMapPoint.x;


}}



I havent got chance to test, but i know it will work (may be little bit tunning need because of upper/lower case letter and spellings) - hope it will help

Zahid
http://zachsgeospatial.blogspot.com
0 Kudos
EricTerpstra
New Contributor
Unfortunately this does not work.  A MultiPoint object is an array of MapPoints, so when I click on a point on the map, event.currentTarget returns a MultiPoint, which cannot be coerced as a MapPoint.  I need a way to distinguish which MapPoint within the MultiPoint was clicked, and as var as I can tell, neither event.target nor event.currentTarget will return this information.

It seems like this should be basic functionality, but I guess a MultiPoint is intended to be one cohesive graphic.  The only solution I can think of is to not use a MultiPoint, but rather loop over my lat/long data and manually add individual MapPoints to the map so that they can each be clicked.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
eterps,

   You are on the right track in thinking that a multipoint graphic is intended to be treated as an single graphic.

the only solution I can think of is to not use a MultiPoint, but rather loop over my lat/long data and manually add individual MapPoints to the map so that they can each be clicked.


This would be your best route.
0 Kudos