MapBox
Создание mbtiles из geojson
Список литературы:
https://github.com/mapbox/tippecanoe утилита для создания
-zg: Automatically choose a maxzoom that should be sufficient to clearly distinguish the features and the detail within each feature
-l name or --layer=name: Use the specified layer name instead of deriving a name from the input filename or output tileset. If there are multiple input files specified, the files are all merged into the single named layer, even if they try to specify individual names with -L.
Пример команды для создания mbtiles tippecanoe --force -o vydel_default.mbtiles vydelsAV.geojson av.geojson
Для переопределения слоёв из стиля
Layer layer = style.getLayer("museums"); if (layer != null) { if (VISIBLE.equals(layer.getVisibility().getValue())) { layer.setProperties(visibility(NONE)); } else { layer.setProperties(visibility(VISIBLE)); } }
Для подключения стиля к слою
Геннадий, попробовать вживую не успел. Но решение следующее:
1. В json стиля задаем пустой источник geojson
"geojson_source":{
"type": "geojson", "data": {"type": "FeatureCollection", "features": [] } }
2. Ниже задаем его стиль. Это может быть сделано двумя способами: 2.1 Создание отдельных слоев по фильтру, например так (слой соответсвует своему ULV_EN ): {'id': 'geojson_layer1', 'type': 'fill', 'source': 'geojson_source', "filter": ["==", "ULV_EN", "Vyazemskoe"], 'layout': {}, 'paint': {'fill-color': '#fbb03b','fill-opacity': 1.0} {'id': 'geojson_layer2', 'type': 'fill', 'source': 'geojson_source', "filter": ["==", "ULV_EN", "Podhorenkovskoe"], 'layout': {}, 'paint': {'fill-color': '#223b53','fill-opacity': 1.0} 2.2 Создание одного слоя с параметрами стиля, зависящими от аттрибутов (также меняем цвет в зависимости от значения ULV_EN ), например так: {'id': 'geojson_layer_comb', 'type': 'fill', 'source': 'geojson_source', "filter": ["==", "ULV_EN", "Podhorenkovskoe"], 'layout': {}, 'paint': { 'fill-color': [ 'match', ['get', 'ULV_EN'], 'Vyazemskoe', '#fbb03b', 'Podhorenkovskoe', '#223b53', / other / '#ccc' ], 'fill-opacity': 1.0}
Выражения, которые можно использовать подробно описаны в документации mapbox https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/
3. В коде заполняем пустой источник данными: mapboxMap.getStyle(new Style.OnStyleLoaded() { @Override public void onStyleLoaded(@NonNull Style style) {
GeoJsonSource geoJsonSource = style.getSourceAs("geojson_source"); geoJsonSource.setGeoJson(assets://geojson);
} });
шрифты
https://github.com/klokantech/mapbox-gl-js-offline-example/tree/gh-pages/font
стили mapbox https://docs.mapbox.com/mapbox-gl-js/style-spec/root
спецификация mbtiles
https://github.com/mapbox/mbtiles-spec
https://gis-lab.info/qa/mbtiles-spec.html
Остальное https://uscensusbureau.github.io/citysdk/examples/mapbox-choropleth/ https://joeyklee.github.io/hello-vector-tiles/ Ссылка на mabpox studio classic https://mapbox.s3.amazonaws.com/mapbox-studio/index.html
Утилита для сборки mbtiles из png https://github.com/mapbox/mbutil/ https://habr.com/ru/post/441296/
Объединять mbtiles:
https://habr.com/ru/post/203212/
Для объединения отдельных файлов MBTiles можно использовать команду: echo '.dump' | sqlite3 file1.mbtiles | sqlite3 file2.mbtiles
Результат будет в файле file2.mbtiles.