I'm trying to add an annotation to the map with the "LongPress-event".
public void OnLongPress(SKScreenPoint point)
{
SKCoordinate point1 = new SKCoordinate(point.GetX(), point.GetY());
SKAnnotation anno1 = new SKAnnotation(10);
anno1.Location = point1;
anno1.MininumZoomLevel = 10;
anno1.AnnotationType = SKAnnotation.SkAnnotationTypeBlue;
_mapView.AddAnnotation(anno1, SKAnimationSettings.AnimationNone);
System.Console.WriteLine(point1);
System.Console.WriteLine(point);
System.Console.WriteLine(anno1);
}
From the Console.WriteLines I get following messages:
[540.9993896484375,1049.2178955078125]
SKScreenPoint [x=540.9994, y=1049.2179]
SKAnnotation [uniqueID=10, location=[540.9993896484375,1049.2178955078125], imagePath=null, imageSize=192, annotationType=33, mininumZoomLevel=10, offset=SKScreenPoint [x=0.0, y=0.0], annotationView=null]
I get the coordinates from my screen display. But I need the coordinates from the map.
How do I do that? Can someone help me please? :)
Thanks.
You'll need to convert the screen point to a "coordinate" via reverse geocoding:
public void onLongPress(SKScreenPoint point) {
SKCoordinate poiCoordinates = mapView.pointToCoordinate(point);
final SKSearchResult place = SKReverseGeocoderManager
.getInstance().reverseGeocodePosition(poiCoordinates);
SKAnnotation annotation = new SKAnnotation(GREEN_PIN_ICON_ID);
annotation.setUniqueID(GREEN_PIN_ICON_ID);
annotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_GREEN);
annotation.setLocation(place.getLocation());
annotation.setMininumZoomLevel(5);
mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_NONE);
}