posm / OpenMapKitAndroid

http://openmapkit.org
BSD 3-Clause "New" or "Revised" License
128 stars 38 forks source link

Marker Icon Misalignment #81

Closed hallahan closed 8 years ago

hallahan commented 8 years ago

I'm working on getting Maki Markers working so that we can have smaller markers as well as custom colors and icons for #31.

The Mapbox Android SDK has built in this capability, however, the Maki markers only work when the device is online, because that image asset is requested from Mapbox's API. You need an API key to be able to request it as well.

So, that is not an option for us...

The CustomMarkerTestFragment.java in the SDK demonstrates that you can alternatively specify the icon of the marker with the setMarker method instead of setIcon (confusing). This lets you use a bitmap asset instead of having to make an HTTP request.

It turns out, however, that it does not correctly align the bitmap to bottom center point that we would expect from a Marker.

Here is a point on OSM where the circle is the actual position, as sourced directly from OpenStreetMap.

screenshot 2015-08-18 15 31 35

We can see that the default marker is being placed correctly in the app:

2015-08-18 22 43 31

Then, look what happens when we use a Maki Marker via the setMarker method:

2015-08-18 22 42 45

Not good at all...

When you actually use the addMarker user interface, you can see this problem directly. Here's what you see right when you press + Add Node:

2015-08-18 23 09 40

I then went in and tried a basic PNG that is 40x40 to see if I can get some insight as to how the SDK is placing the image:

2015-08-18 22 41 58

It does not seem to place the bottom edge at the center point of the node. Something is wrong.

cc/ @dalekunce @mberg @bleege @jharpster

hallahan commented 8 years ago

By nudging the anchor, we're able to offset the bitmap to the right point.