MapboxMap에 VectorSource를 추가하기 위해 Android Mapbox SDK를 사용하고 있는데,지도에 LineLayer도 추가하려고합니다. LineLayer의 MapBox setProperties가 해결되지 않습니다.
현재는 네이티브 라이브러리 및 네이티브 안드로이드/아이폰 OS API에 직접 액세스의 소비를 수있는 NativeScript 프레임 워크를 사용하고 있기 때문에이 코드는 타이프에 될 것입니다 버전 5.1.3를 사용하여.
// these constants are just simple ways to reference a class in the mapbox package
const PropertyFactory = com.mapbox.mapboxsdk.style.layers.PropertyFactory;
const Property = com.mapbox.mapboxsdk.style.layers.Property;
const LineLayer = com.mapbox.mapboxsdk.style.layers.LineLayer;
const VectorSource = com.mapbox.mapboxsdk.style.sources.VectorSource;
const lineCap = com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap;
const lineColor = com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor;
const lineJoin = com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin;
const lineWidth = com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;
const LatLngBounds = com.mapbox.mapboxsdk.geometry.LatLngBounds;
const FillLayer = com.mapbox.mapboxsdk.style.layers.FillLayer;
const SymbolLayer = com.mapbox.mapboxsdk.style.layers.SymbolLayer;
const CircleLayer = com.mapbox.mapboxsdk.style.layers.CircleLayer;
// set the map GLSource (vector) to the mapbox map
const vectorSource = new VectorSource(
layer.ID.toString(),
`http://themaptiles.cloudapp.net/data/${layer.GLSource}.json`
);
this._mapboxMap.addSource(vectorSource);
let newLayer;
if (layer.Type == "line") {
console.log(`*** creating new LineLayer ***`);
newLayer = new LineLayer("line-layer", layer.ID.toString());
// get the line color for this style
const lColor = style["line"]["line-color"];
const androidColor = new Color(lColor).android; // ends up valid and something like -1293839 for android to use
newLayer.setSourceLayer(layer.ID.toString());
// will throw here with `Failed resolving method setProperties on class com.mapbox.mapboxsdk.style.layers.Layer`
newLayer.setProperties(
PropertyFactory.lineJoin(Property.LINE_JOIN_ROUND),
PropertyFactory.lineCap(Property.LINE_CAP_ROUND),
PropertyFactory.lineColor(androidColor),
PropertyFactory.lineWidth(new java.lang.Float(2))
);
}
this._mapboxMap.addLayer(newLayer);
내가 setProperties
방법 다음 코드가 잘 실행하지만 레이어가 추가 된 후지도에 보이는 라인이 존재하지를 사용하지 않는 경우
안녕하세요 @ 브래드 마틴, 당신은 속성의 배열을'setProperties' 가변 방식으로 전달할 수 있습니까? – pkanev
감사합니다 @ pkanev - 배열로 설정을 전달하면 실제로 예외가 발생하지 않습니다. –