使用 LongPress 事件创建注释
create annotation with LongPress event
我正在尝试使用 "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);
}
从 Console.WriteLines 我收到以下消息:
[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]
我从屏幕显示中获取坐标。但是我需要地图上的坐标。
我该怎么做?
有谁可以帮助我吗? :)
谢谢。
您需要通过反向地理编码将屏幕点转换为 "coordinate":
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);
}
我正在尝试使用 "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);
}
从 Console.WriteLines 我收到以下消息:
[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]
我从屏幕显示中获取坐标。但是我需要地图上的坐标。
我该怎么做? 有谁可以帮助我吗? :)
谢谢。
您需要通过反向地理编码将屏幕点转换为 "coordinate":
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);
}