当我将 x 和 y 坐标添加到 MapView.LayoutParams 构造函数时。它的 MODE_VIEW 行为消失了。我想要这种行为以及 x 和 y 坐标。我不明白为什么会这样。
public void addMarkerToMAp(GeoPoint geoPoint) {
mapView.removeAllViews();
final ImageView view = new ImageView(mapView.getContext());
view.setImageResource(R.drawable.map_marker_anim);
view.post(new Runnable() {
@Override
public void run() {
AnimationDrawable animationDrawable = (AnimationDrawable) view.getDrawable();
animationDrawable.start();
}
});
mapView.addView(view);
MapView.LayoutParams layoutParams = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT,
MapView.LayoutParams.WRAP_CONTENT,
geoPoint,
MapView.LayoutParams.MODE_VIEW);
view.setLayoutParams(layoutParams);
}
所以,我得到了 geoPoint 作为
geoPoint = mapView.getProjection().fromPixels((int)event.getX(), (int)event.getY()); 其中事件是点击事件。
我还想在(event.getX(),event.getY())处显示标记图钉,但它显示在点击下方。