draw a line into some geopoints mapsforge-map

204 views
Skip to first unread message

Alireza Parnia

unread,
May 30, 2018, 7:50:58 AM5/30/18
to mapsforge-dev
hi
how can i draw some continuously lines between some geopoints.
with this code we can but fill the area with the color. i dont want to fill the area:
 Paint paint = AndroidGraphicFactory.INSTANCE.createPaint();
 paint
.setColor(android.graphics.Color.parseColor("#772F4198"));
paint
.setStrokeWidth(3);
 
Polyline polyline = new Polyline(paint, AndroidGraphicFactory.INSTANCE);
 
List<LatLong> coordinateList = polyline.getLatLongs();

 
//coordinateList.addAll(coordList);
 coordinateList
.add(new LatLong(36.43454,52.4154133));
 coordinateList
.add(new LatLong(36.440905,52.4203833));
 coordinateList
.add(new LatLong(36.4477033,52.42351));
 coordinateList
.add(new LatLong(36.4476467,52.4235267));
 mapView
.getLayerManager().getLayers().add(polyline);


Emux

unread,
May 30, 2018, 8:06:31 AM5/30/18
to mapsfo...@googlegroups.com
Don't understand the question. With polyline layer can draw lines on map, based on a series of coordinates. What else do you mean?

--
Emux

Alireza Parnia

unread,
May 30, 2018, 8:43:32 AM5/30/18
to mapsforge-dev
sorry for bad question.
i mean draw line between some geopoints what i want to do. but with above code will draw a poligone between my coordinates.

Alireza Parnia

unread,
May 30, 2018, 8:46:42 AM5/30/18
to mapsforge-dev
this method will work well:

public int createPolyline(List<LatLong> coordinates, float strokeWidth) {
 
Paint paint = AndroidGraphicFactory.INSTANCE.createPaint();
 paint
.setStyle(Style.STROKE);
 paint
.setColor(android.graphics.Color.parseColor("#772F4198"));
 paint
.setStrokeWidth(strokeWidth);

 
Polyline pl = new Polyline(paint,AndroidGraphicFactory.INSTANCE);
 pl
.getLatLongs().addAll(coordinates);
 mapView
.getLayerManager().getLayers().add(pl);
 mapView
.getLayerManager().redrawLayers();
 
return pl.hashCode();
}


 it seems needed to setStyle parameters.

Emux

unread,
May 30, 2018, 8:49:55 AM5/30/18
to mapsfo...@googlegroups.com
It's recommended always to check library samples where all these are demonstrated.
e.g. OverlayMapViewer

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