Incorrect localization of markers on map. Strange behaviour of markers on the map
I works with OSMdroid. I extended the Overlay class and I overridden the draw method to my needs. And I have a problem with placing of markers. When I display them for the first time they have wrong location. But when I start zooming they move and after couple of zooms they have correct localization.
Here is my code:
protected final Rect mRect = new Rect();
protected Point mScreenPts = new Point();
@Override
protected void draw(Canvas c, MapView osmv, boolean shadow) {
Projection pj = osmv.getProjection();
synchronized (mInternalItemList) {
if (shadow && !mInternalItemList.isEmpty()) {
for(int i = 0; i < mInternalItemList.size(); i++) {
CustomizedItem customized = mInternalItemList.get(i);
pj.toMapPixels(new GeoPoint(customized.getLatitude(),
customized.getLongitude()), mScreenPts);
boundToHotspot(customized.getDrawable(), HotspotPlace.LOWER_LEFT_CORNER);
Drawable draw = customized.getDrawable();
draw.copyBounds(mRect);
draw.setBounds(mRect.left + mScreenPts.x, mRect.top + mScreenPts.y,
mRect.right + mScreenPts.x, mRect.bottom + mScreenPts.y);
draw.draw(c);
draw.setBounds(mRect);
}
}
}
}
Thank in advance.
Read more
stackoverflow.comm