Варианты подложек #14

Closed
opened 3 years ago by g · 5 comments
g commented 3 years ago
Owner

Пользователь может выбирать карты-подложки:

  1. та, которая сейчас есть
  2. mapbox topo
  3. спутник
Пользователь может выбирать карты-подложки: 1. та, которая сейчас есть 2. mapbox topo 3. спутник
g commented 3 years ago
Poster
Owner
https://git.iamonlyherefortheicecream.ml/MRC/geodata-catalog/commit/ed609322fa77ce1b57317e99f6950335b8bcaa7d
g commented 3 years ago
Poster
Owner
https://git.iamonlyherefortheicecream.ml/MRC/geodata-catalog/commit/f838889afd6f95a7c3a8f303685ae77a0cb5142c
g commented 3 years ago
Poster
Owner
const basemapTiles = {
  "topo": [`https://api.mapbox.com/styles/v1/ghermant/cl9vd1nji002n15s2xxj25f4m/tiles/256/{z}/{x}/{y}@2x?access_token=${apiKey}`],
  "satellite": [`https://api.mapbox.com/styles/v1/ghermant/cl9olarp0002i14vq9a2d0e7g/tiles/256/{z}/{x}/{y}@2x?access_token=${apiKey}`],
  "mono": [`https://api.mapbox.com/styles/v1/ghermant/cl9vd7xwi004u14nxu3j83scj/tiles/256/{z}/{x}/{y}@2x?access_token=${apiKey}`]
}

map.value.addSource("basemap", {
  type: "raster",
  tiles: [
    basemapTiles["topo"]
  ],
});

map.value.addLayer({
  id: "basemap-layer",
  type: "raster",
  source: "basemap",
  paint: {},
});


function () {
	const selectedBasemap = this.value
	map.value.getSource('basemap').setTiles(basemapTiles[selectedBasemap])
}
```js const basemapTiles = { "topo": [`https://api.mapbox.com/styles/v1/ghermant/cl9vd1nji002n15s2xxj25f4m/tiles/256/{z}/{x}/{y}@2x?access_token=${apiKey}`], "satellite": [`https://api.mapbox.com/styles/v1/ghermant/cl9olarp0002i14vq9a2d0e7g/tiles/256/{z}/{x}/{y}@2x?access_token=${apiKey}`], "mono": [`https://api.mapbox.com/styles/v1/ghermant/cl9vd7xwi004u14nxu3j83scj/tiles/256/{z}/{x}/{y}@2x?access_token=${apiKey}`] } map.value.addSource("basemap", { type: "raster", tiles: [ basemapTiles["topo"] ], }); map.value.addLayer({ id: "basemap-layer", type: "raster", source: "basemap", paint: {}, }); function () { const selectedBasemap = this.value map.value.getSource('basemap').setTiles(basemapTiles[selectedBasemap]) } ```
g commented 3 years ago
Poster
Owner
function () {
    const selectedBasemap = this.value
    map.value.removeSource("basemap")
    map.value.addSource("basemap", {
    	type: "raster",
    	tiles: [
      		basemapTiles[selectedBasemap]
    	])
    }
}
```js function () { const selectedBasemap = this.value map.value.removeSource("basemap") map.value.addSource("basemap", { type: "raster", tiles: [ basemapTiles[selectedBasemap] ]) } } ```
g commented 3 years ago
Poster
Owner
const selectedBasemap = this.value
map.value.getSource('basemap').tiles = basemapTiles[selectedBasemap]
map.value.style.sourceCaches['basemap'].clearTiles()
// Load the new tiles for the current viewport (map.value.transform -> viewport)
map.value.style.sourceCaches['basemap'].update(map.value.transform)
// Force a repaint, so that the map will be repainted without you having to touch the map
map.value.triggerRepaint()

```js const selectedBasemap = this.value map.value.getSource('basemap').tiles = basemapTiles[selectedBasemap] map.value.style.sourceCaches['basemap'].clearTiles() // Load the new tiles for the current viewport (map.value.transform -> viewport) map.value.style.sourceCaches['basemap'].update(map.value.transform) // Force a repaint, so that the map will be repainted without you having to touch the map map.value.triggerRepaint() ```
g closed this issue 3 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: MRC/geodata-catalog#14
Loading…
There is no content yet.