混合 SKAnnotations 自定义视图
Mixed SKAnnotations customViews
我无法将 SKAnnotations 重新添加到我的地图。
该地图显示了印度 2 个城市的 2 个 SKAnnotations:新德里和昌迪加尔(新德里的布局包含白色背景,而昌迪加尔只是一个带有 TextView 的新 RelativeLayout)。
在几轮删除所有 SKAnnotations 然后重新添加它们之后,customViews 变得混乱了。地图应该是这样的:
下面是一些删除和重新添加后可能会发生的情况:
添加注释的代码:
public void addAnnotations() {
SKAnnotation newDelhi = new SKAnnotation(444);
newDelhi.setMininumZoomLevel(5);
newDelhi.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_MARKER);
SKAnnotationView newDelhiAnnotationView = new SKAnnotationView();
RelativeLayout newDelhiCustomView =
(RelativeLayout) ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
R.layout.annotation_layout, null, false);
newDelhiCustomView.setTag("new delhi");
newDelhiAnnotationView.setView(newDelhiCustomView);
newDelhi.setAnnotationView(newDelhiAnnotationView);
TextView newDelhiTextView = (TextView) newDelhiAnnotationView.getView().findViewById(R.id.annotation_textview);
newDelhiTextView.setText("New Delhi");
SKCoordinate newDelhiLocation = new SKCoordinate(77.179163, 28.619828);
newDelhi.setLocation(newDelhiLocation);
SKAnnotation chandigarh = new SKAnnotation(555);
chandigarh.setMininumZoomLevel(5);
chandigarh.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_MARKER);
SKAnnotationView chandigahrAnnotationView= new SKAnnotationView();
RelativeLayout chandigarhCustomView =
new RelativeLayout(getActivity());
chandigarhCustomView.setTag("chandigarh");
TextView chandigarhTextView = new TextView(getActivity());
chandigarhTextView.setText("Chandigarh");
chandigarhCustomView.addView(chandigarhTextView);
chandigahrAnnotationView.setView(chandigarhCustomView);
chandigarh.setAnnotationView(chandigahrAnnotationView);
SKCoordinate chandigarhLocation = new SKCoordinate(76.778867,30.736094);
chandigarh.setLocation(chandigarhLocation);
String nd = (String)newDelhiAnnotationView.getView().getTag();
String ch = (String)chandigahrAnnotationView.getView().getTag();
mapView.addAnnotation(newDelhi, SKAnimationSettings.ANIMATION_NONE);
mapView.addAnnotation(chandigarh, SKAnimationSettings.ANIMATION_NONE);
}
通过调用删除注释:
mapView.deleteAllAnnotationsAndCustomPOIs();
在尝试处理这个问题大约一周后,我完全不知所措,TIA
这是旧版 SDK(我认为 <= 2.5.0)中的一个问题,SDK 没有正确管理注释的 ID(因此有时会删除错误的注释)。
在 2.5.1 中这是固定的(显示在 release notes) by exposing the uniqueID 属性.
我无法将 SKAnnotations 重新添加到我的地图。 该地图显示了印度 2 个城市的 2 个 SKAnnotations:新德里和昌迪加尔(新德里的布局包含白色背景,而昌迪加尔只是一个带有 TextView 的新 RelativeLayout)。 在几轮删除所有 SKAnnotations 然后重新添加它们之后,customViews 变得混乱了。地图应该是这样的:
下面是一些删除和重新添加后可能会发生的情况:
添加注释的代码:
public void addAnnotations() {
SKAnnotation newDelhi = new SKAnnotation(444);
newDelhi.setMininumZoomLevel(5);
newDelhi.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_MARKER);
SKAnnotationView newDelhiAnnotationView = new SKAnnotationView();
RelativeLayout newDelhiCustomView =
(RelativeLayout) ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
R.layout.annotation_layout, null, false);
newDelhiCustomView.setTag("new delhi");
newDelhiAnnotationView.setView(newDelhiCustomView);
newDelhi.setAnnotationView(newDelhiAnnotationView);
TextView newDelhiTextView = (TextView) newDelhiAnnotationView.getView().findViewById(R.id.annotation_textview);
newDelhiTextView.setText("New Delhi");
SKCoordinate newDelhiLocation = new SKCoordinate(77.179163, 28.619828);
newDelhi.setLocation(newDelhiLocation);
SKAnnotation chandigarh = new SKAnnotation(555);
chandigarh.setMininumZoomLevel(5);
chandigarh.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_MARKER);
SKAnnotationView chandigahrAnnotationView= new SKAnnotationView();
RelativeLayout chandigarhCustomView =
new RelativeLayout(getActivity());
chandigarhCustomView.setTag("chandigarh");
TextView chandigarhTextView = new TextView(getActivity());
chandigarhTextView.setText("Chandigarh");
chandigarhCustomView.addView(chandigarhTextView);
chandigahrAnnotationView.setView(chandigarhCustomView);
chandigarh.setAnnotationView(chandigahrAnnotationView);
SKCoordinate chandigarhLocation = new SKCoordinate(76.778867,30.736094);
chandigarh.setLocation(chandigarhLocation);
String nd = (String)newDelhiAnnotationView.getView().getTag();
String ch = (String)chandigahrAnnotationView.getView().getTag();
mapView.addAnnotation(newDelhi, SKAnimationSettings.ANIMATION_NONE);
mapView.addAnnotation(chandigarh, SKAnimationSettings.ANIMATION_NONE);
}
通过调用删除注释:
mapView.deleteAllAnnotationsAndCustomPOIs();
在尝试处理这个问题大约一周后,我完全不知所措,TIA
这是旧版 SDK(我认为 <= 2.5.0)中的一个问题,SDK 没有正确管理注释的 ID(因此有时会删除错误的注释)。
在 2.5.1 中这是固定的(显示在 release notes) by exposing the uniqueID 属性.