[VTM][Android] Screen position in pixels

76 views
Skip to first unread message

Jaca

unread,
Feb 7, 2021, 5:05:41 AM2/7/21
to Mapsforge & VTM
Hi,

How to convert geoPoint to screen coordinates having bearing & tilt? I want to draw (on the fly) a lot of custom markers on MapView canvas (dispatchDraw(Canvas canvas)).

Jacek

Emux

unread,
Feb 7, 2021, 5:12:48 AM2/7/21
to mapsfo...@googlegroups.com
You can find such utilities in MercatorProjection class.

--
Emux

Emux

unread,
Feb 7, 2021, 5:19:44 AM2/7/21
to mapsfo...@googlegroups.com
But the markers are set properly on coordinates (and the map rotates / tilt them) - not on pixels.

--
Emux

Jaca

unread,
Feb 7, 2021, 6:11:02 AM2/7/21
to Mapsforge & VTM
But my markers change position and appearance. MercatorProjection.getPixel() doesn't work with rotation.

ps. Google.mapGoogleMap.getProjection().toScreenLocation() works OK. ;-)

Emux

unread,
Feb 7, 2021, 6:13:16 AM2/7/21
to mapsfo...@googlegroups.com
See the marker example in the samples for how to properly add markers on map.

--
Emux

Jaca

unread,
Feb 9, 2021, 7:20:46 AM2/9/21
to Mapsforge & VTM
I tried but update of markers is too slow because everyone has their own (drawn on the fly) bitmap.

Jaca

unread,
Feb 15, 2021, 7:15:02 AM2/15/21
to Mapsforge & VTM
;-)
... I'm optimizing display and I've a question: how to simple show/hide created marker(s) by setVisible(true/false)?

Emux

unread,
Feb 15, 2021, 7:36:17 AM2/15/21
to mapsfo...@googlegroups.com
You can use the setEnabled method on the layer or remove / add the markers in the ItemizedLayer.

--
Emux

Jaca

unread,
Mar 18, 2021, 4:22:10 AM3/18/21
to Mapsforge & VTM
Hi Emux, ;-)

I have a problem with the VectorLayer. Could You check why a shape on the VectorLayer doesn't show very often after starting VectorLayerActivity?

Use VectorLayerActivity from examples and:
1. change number of shapes to one
2. increase size of shape
3. change position to fixed GeoPoint(0.0f, 0.0f)
4. run several times...

The map needs to be moved to refresh (and display shape) very often.

Emux

unread,
Mar 18, 2021, 4:31:48 AM3/18/21
to mapsfo...@googlegroups.com
Please create new topics for new questions, so that users can search them easier in the future.


> The map needs to be moved to refresh (and display shape) very often.

You need to call the vectorLayer.update() like in the sample.

--
Emux
Reply all
Reply to author
Forward
0 new messages