Marker onClickListener

6394
14
Jump to solution
07-26-2016 07:20 AM
MohamedEzzerI
New Contributor III

Hi, Everyone : is there any clicklistener for marker in ArcGis runtime sdk for android,

0 Kudos
1 Solution

Accepted Solutions
MohamedEzzerI
New Contributor III

Thanks for your help, i succeed to do it, using this code :

public void markerClick() {

mvHelper.setOnGraphicClickListener(new OnGraphicClickListener() {

@Override

public void onGraphicClick(Graphic graphic) {

double gX, gY;

mvHelper.setShowGraphicCallout(false);

gX = ((Point)graphic.getGeometry()).getX();

gY = ((Point)graphic.getGeometry()).getY();

Point p = new Point(gX, gY);

Point newPoint =

(Point) GeometryEngine.project(p,

arcMap.getSpatialReference(), SpatialReference.create(4326));

Toast.makeText(ctx, String.valueOf(newPoint.getX()) + " "

+ String.valueOf(newPoint.getY()), Toast.LENGTH_LONG).show();

}

});

}

2016-07-28 17:43 GMT+01:00 Alexander Nohe <geonet@esri.com>:

GeoNet <https://community.esri.com/?et=watches.email.thread>

Marker onClickListener

reply from Alexander Nohe

<https://community.esri.com/people/ANohe-esristaff?et=watches.email.thread>

in ArcGIS Runtime SDK for Android - View the full discussion

<https://community.esri.com/message/624384?et=watches.email.thread#comment-624384>

View solution in original post

14 Replies
AlexanderNohe1
Occasional Contributor III

I do not believe that there is a listener for this class (MarkerSymbol | ArcGIS Android 10.2.8 API ).

Instead, I would implement an OnSingleTapListener on the map object and check if there are any markers there using a query.  If there are, then handle the OnSingleTap as you wish. ( SingleTapListener )

Is there something special you wanted to do with selecting marker symbols when clicking on the MapView?

MohamedEzzerI
New Contributor III

Thanks for the feedback, i don't how can i check if there are any markers

there using a query, i wish that u can send me an example of code which

could help me

2016-07-26 15:56 GMT+01:00 Alexander Nohe <geonet@esri.com>:

GeoNet <https://community.esri.com/?et=watches.email.thread>

Marker onClickListener

reply from Alexander Nohe

<https://community.esri.com/people/ANohe-esristaff?et=watches.email.thread>

in ArcGIS Runtime SDK for Android - View the full discussion

<https://community.esri.com/message/623545?et=watches.email.thread#comment-623545>

0 Kudos
AlexanderNohe1
Occasional Contributor III

You would query against whatever geometry is showing the marker. This is generally a feature service layer or graphics layer.  Do you know what is supporting the underlying geometry of the marker symbol?

0 Kudos
MohamedEzzerI
New Contributor III

Not really, I m using arcGis for the first time, so it s quite difficult to

use it even after reading the api

Le 27 juil. 2016 18:26, "Alexander Nohe" <geonet@esri.com> a écrit :

GeoNet <https://community.esri.com/?et=watches.email.thread>

Marker onClickListener

reply from Alexander Nohe

<https://community.esri.com/people/ANohe-esristaff?et=watches.email.thread>

in ArcGIS Runtime SDK for Android - View the full discussion

<https://community.esri.com/message/623979?et=watches.email.thread#comment-623979>

0 Kudos
AlexanderNohe1
Occasional Contributor III

Hello Mohamed EzzerI​,

How are you creating the markers?

This should give us some insight in to how best to assist you in querying for their values.

0 Kudos
MohamedEzzerI
New Contributor III

i have a JSON and i parse it to create my markers

Le 28 juil. 2016 13:11, "Alexander Nohe" <geonet@esri.com> a écrit :

GeoNet <https://community.esri.com/?et=notification.mention>

You have been mentioned

by Alexander Nohe

<https://community.esri.com/people/ANohe-esristaff?et=notification.mention> *in

Re: Marker onClickListener in GeoNet* - View Alexander Nohe's reference

to you

<https://community.esri.com/message/624281?et=notification.mention#comment-624281>

0 Kudos
AlexanderNohe1
Occasional Contributor III

Can you upload the smallest reproducible test case that you have?  I may gain better insight if I can see what exactly you are doing.

Thank you!

0 Kudos
MohamedEzzerI
New Contributor III

Thanks for your help, i succeed to do it, using this code :

public void markerClick() {

mvHelper.setOnGraphicClickListener(new OnGraphicClickListener() {

@Override

public void onGraphicClick(Graphic graphic) {

double gX, gY;

mvHelper.setShowGraphicCallout(false);

gX = ((Point)graphic.getGeometry()).getX();

gY = ((Point)graphic.getGeometry()).getY();

Point p = new Point(gX, gY);

Point newPoint =

(Point) GeometryEngine.project(p,

arcMap.getSpatialReference(), SpatialReference.create(4326));

Toast.makeText(ctx, String.valueOf(newPoint.getX()) + " "

+ String.valueOf(newPoint.getY()), Toast.LENGTH_LONG).show();

}

});

}

2016-07-28 17:43 GMT+01:00 Alexander Nohe <geonet@esri.com>:

GeoNet <https://community.esri.com/?et=watches.email.thread>

Marker onClickListener

reply from Alexander Nohe

<https://community.esri.com/people/ANohe-esristaff?et=watches.email.thread>

in ArcGIS Runtime SDK for Android - View the full discussion

<https://community.esri.com/message/624384?et=watches.email.thread#comment-624384>

AlexanderNohe1
Occasional Contributor III

Do you still require assistance with this or did this code resolve the issue for you?