Precise positioning of markers for lat/lon
I'm trying to centre a 40x40 marker at a lat/lon position in an ite开发者_运维问答mizedOverlay for a mapview.
I set the marker bounds with
markerDefault.setBounds( -markerDefault.getIntrinsicWidth()/2
,-markerDefault.getIntrinsicHeight()/2
, markerDefault.getIntrinsicWidth()/2
, markerDefault.getIntrinsicHeight()/2);
When I check the lat/lon by tapping the centre of the marker image, the lat seems to be wrong by about the height of the image.
Is there a way to ensure the image is centred at the required lat/lon?
Is it possible the default mouse cursor - an arrow - isn't doing its usual behaviour of using its pointy end to interact with the emulator?
Thanks,
Geoff
The answer -
I'm using an ItemisedOverlay. When an OverlayItem is added, you can specify whether the marker is positioned with its centre at the position, or its lower edge at the position. See ItemizedOverlay.
I had copy-and-pasted some nice code for an ItemizedOverlay I found( on stackoverflow of course), which included
super(boundCenterBottom(defaultMarker));
This caused the apparent anomaly I found. Its good if you're using a pin-type marker tho. I changed it to
super(boundCenter(defaultMarker));
and it works as expected.
精彩评论