moagrius / MapView

(Deprecated, prefer https://github.com/moagrius/TileView) Android widget roughly described as a hybrid between com.google.android.maps.MapView and iOS's CATiledLayer
http://moagrius.github.com/MapView/documentation
69 stars 35 forks source link

Markers moving when zooming #54

Closed novagen closed 11 years ago

novagen commented 11 years ago

My markers do not stay in the same place when I zoom on the map. As I zoom out they more further and further away from their original position.

Map created with:

mapView.setBackgroundColor(Color.BLACK);
mapView.setMarkerAnchorPoints(0.5f, 1f);
mapView.setShouldIntercept(true);
mapView.setCacheEnabled(true);

Marker inserted as:

mapView.addMarker(createMarkerView(this, "TEST"), 500, 500);

The createMarkerView function:

private ImageView createMarkerView(final Context context, final String title) {
        ImageView imageView = new ImageView(context);
        imageView.setImageResource(R.drawable.current_position);
        imageView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Logging.toast(context, title);
            }
        });

        return imageView;
}
moagrius commented 11 years ago

you probably want to change this line:

mapView.setMarkerAnchorPoints(0.5f, 1f);

to this:

mapView.setMarkerAnchorPoints(-0.5f, -1f);

novagen commented 11 years ago

Thanks! That solved it.