//Hi, Guys. Below is the simple example to change the properties of polygon border. Hope it will help you.//
{
List<LatLng> plotPolygon = new ArrayList<>();
List<com.mapbox.services.commons.models.Position> coordinates = new ArrayList<>();
plotPolygon.add(new LatLng(18.9965099,75.7316343));
plotPolygon.add(new LatLng(20.8858018,74.7288414));
plotPolygon.add(new LatLng(21.1612315,79.0024702));
plotPolygon.add(new LatLng(18.7918749,78.899195));
plotPolygon.add(new LatLng(18.9965099,75.7316343));
Polygon polygon1 = mapboxMap.addPolygon(new PolygonOptions()
.addAll(plotPolygon)
);
polygon1.setFillColor(Color.parseColor("#3bb2d0"));
다음은 다각형 테두리 좌표 목록을 작성하는 것입니다.
coordinates.add(com.mapbox.services.commons.models.Position.fromCoordinates(75.7316343 , 18.9965099));
coordinates.add(com.mapbox.services.commons.models.Position.fromCoordinates(74.7288414 , 20.8858018));
coordinates.add(com.mapbox.services.commons.models.Position.fromCoordinates(79.0024702 , 21.1612315));
coordinates.add(com.mapbox.services.commons.models.Position.fromCoordinates(78.899195 , 18.7918749));
coordinates.add(com.mapbox.services.commons.models.Position.fromCoordinates(75.7316343 , 18.9965099));
changeStrokeProperties(mapboxMap , coordinates);
}
public void changeStrokeProperties(MapboxMap mapboxMap , List<com.mapbox.services.commons.models.Position> coordinates) {
// Create the LineString from the list of coordinates and then make a GeoJSON//
// FeatureCollection so we can add the line to our map as a layer.//
final Feature lineFeature = Feature.fromGeometry(LineString.fromCoordinates(coordinates));
final GeoJsonSource source = new GeoJsonSource(
"route", FeatureCollection.fromFeatures(new Feature[] { lineFeature }));
mapboxMap.addSource(source);
LineLayer lineLayer = new LineLayer("linelayer", "route");
lineLayer.setProperties(
PropertyFactory.lineDasharray(new Float[]{0.01f, 2f}),
PropertyFactory.lineCap(Property.LINE_CAP_ROUND),
PropertyFactory.lineJoin(Property.LINE_JOIN_ROUND),
PropertyFactory.lineWidth(5f),
PropertyFactory.lineColor(Color.parseColor("#e55e5e"))
);
mapboxMap.addLayer(lineLayer);
}
많은 정보를 제공해 주셔서 감사합니다. 참고 사항 새로운 런타임 스타일로 덮여 있었다는 느낌을주는 github에서 닫힌 두 장의 티켓이 있습니다. https://github.com/mapbox/mapbox-gl-native/issues/1737 https://github.com/mapbox/mapbox-gl-native/issues/324 –
다소 오래된 티켓;) 실제로 런타임 스타일을 구현하기 전에 이것은 방법이었습니다. 우리는 여전히 SDK를 개선하기 위해 노력 중이며 다음 릴리스에서 주석 (폴리곤 포함) 개선을 고려했습니다. – cammace