I develop an Android app that uses the MapsForge plugin to display a map.
I want to display 2000 points on my map. Currently I use FixedPixelCircle
to do that which gives me a nice circle for each point that I can fill with a color I like to indicate different point status.
The problem is that FixedPixelCircle
is a layer and I have to add 2000 layers to my map
getMapView().getLayerManager().getLayers().add(myFixedPixelCircle);
which leads to an OutofMemoryError
or is extremely slow. I read that each layer needs about 3MB.
Now I am looking for a different way of displaying the points. Can I somehow add multiple shapes to a single layer?
I ended up using the code of Circle
- a class of MapsForge that displays a single circle in a layer. I just did not only draw a single cirle in this layer, but all the shapes I wanted.
public class PointLayer extends TileRendererLayer {
@Override
public void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point canvasPosition) {
super.draw(boundingBox, zoomLevel, canvas, canvasPosition);
for (Point p : myPoints) {
//pretty much use the circle code to draw the point
}
}
}
See the MapsForge Cicle code