當我將x和y座標添加到MapView.LayoutParams構造函數。其MODE_VIEW行爲消失。我想要這個行爲以及x和y座標。我不明白爲什麼會發生這種情況。爲什麼如果添加x和y座標,MapView.LayoutParams MODE_VIEW不起作用?
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())顯示標記引腳,但它顯示在點擊下方。