MapView with setMapVisibleArea has different margin depending on the "zoomlevel"

Dear forum,

I am using the MapView class to get a part of a map based on the current position. I have 3 "zoom levels" around the current GPS position. Based on the zoom level, I calculate the position boundaries of the map, i.e. the top-left and right-bottom. 

In order to check my app, I added a marker in each corner of the map.

What I noticed is

1) the margin differs between the maker and the edge of the map picture for each zoom level. See attached picture

2) the center is not the center of the map on the screen

I would expect that the markers would be exactly on the edge of the map in each corner.

At the moment, I am stuck. This is an issue for me, because I want to overlay a bitmap on top of the map with the exact coordinates as for the map, i.e. top-left and right-bottom.

Who can help me solving this issue?

Thanks!

Regards,

Edwin

  • A few things here....

    There's setMapVisibleArea() and setScreenVisibleArea() and how these are defined, could explain why the "center" is shifted up.

    Also, when calling setMapVisibleArea(), what you get is a map that includes that but it may not be the actual size you specified, so as you see the "border" might grow based on the maps.

    To complicate things, in the sim you're getting the maps from OpenStreetMaps, vs the onboard maps on a device, so there are also differences due to that.

    One of the differences between MapVivew and MapTrackView, is that with MapTrackView, the map stays centered on your current location, so depending on what you wnat to do in your app, MapTrackView might work better.

    General advice about maps.  You want to use a real device for much of the testing, as the sim doesn't work quite the same way as a device.  For example, on a device, if you have track log = show, you get a track log on the map you see the actual scale of the map, etc

  • Former Member
    0 Former Member

    The mapping engine has discreet zoom levels, and cannot zoom to the exact coordinates you specify. It will zoom to the narrowest available zoom that can contain the bounding box you have specified. These discreet levels are not guaranteed to match from device to device, or in the simulator. Overlaying bitmaps is not a supported use case with the tools currently available.  In theory you could get there by analyzing the specific zoom levels available on your target device, but it is not recommended.

  • Thanks for both replies. 

    Is it be possible to get the 4 corner coordinates from the map that is visible on the screen?

  • At this time, there really is no way to do any kind of map coordinate to screen coordinate mapping.  So there is no way you can reliably do drawing that is map location specific. Hopefully some kind of map coordinate to display coordinate transform will eventually be added.  For now, you'd need to use Markers and Polylines allowing the map engine to do the drawing for you.

    It actually gets much trickier than that as well.  Many of the map settings currently depend on the last activity that was run by the user.  Map orientation and selected maps immediately come to mind.  With North up, you almost have a fighting chance.  But with Heading Up, you can't even be sure of the rotation of the drawn map.