android
android copied to clipboard
Feature Request / Question: Map Center Offset
I'm doing a routing app. I'd like to apply a vertical offset to the map center (where I place the vehicle icon) so it lies at 75% of the screen height. To achieve it I'm using a trick and just setup the MapView bigger than the screen, but I wonder if it Is possible to do it as camera parameter or Tangram function? Thx in advance.
This feature is not currently supported by the Android SDK or Tangram but I agree it would be cool to have.
There is some code here (that I believe @matteblair originally wrote) that could help you implement a workaround without needing to make the MapView bigger than the screen.
https://github.com/mapzen/eraser-map/blob/master/app/src/main/kotlin/com/mapzen/erasermap/view/RouteModeView.kt#L261-L304
Ah you found it before me, thanks Chuck!
Thanks so much @ecgreb and @matteblair , I've tested the solution. Just one question, as seen in @matteblair 's code, what is the benefit of calling map.setPosition, etc... via map.queueEvent()? I've seen it posts the runnable to the MapView's SurfaceView. In my code I was calling it directly. Should I always queue the position / rotation change requests?
map.queueEvent() is useful when you need to execute several updates or position changes directly after one another - if you make sequential set calls directly then the map might render between these calls in an unintended position.
Ohh that explains why your map centering routine doesn't cause a jump or flickers when changing mapPosition two times in sequence! I was really wondering why it didn't happen!