android icon indicating copy to clipboard operation
android copied to clipboard

Feature Request / Question: Map Center Offset

Open nebular opened this issue 8 years ago • 5 comments

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.

nebular avatar Mar 04 '17 20:03 nebular

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

ecgreb avatar Mar 06 '17 22:03 ecgreb

Ah you found it before me, thanks Chuck!

matteblair avatar Mar 06 '17 23:03 matteblair

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?

nebular avatar Mar 07 '17 00:03 nebular

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.

matteblair avatar Mar 07 '17 16:03 matteblair

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!

nebular avatar Mar 08 '17 21:03 nebular