From cec06448634c6fdaf921db711fee9824a5878d66 Mon Sep 17 00:00:00 2001 From: xdan Date: Tue, 19 Sep 2023 18:46:26 +0300 Subject: [PATCH] New version 1.0.26 --- example/common.js | 25 ++++++++++++--- example/vanilla.html | 31 ++++++++++++++++--- package-lock.json | 4 +-- package.json | 2 +- .../db-data-provider/db-data-provider.ts | 2 +- src/app/v1/load-by-tile-cluster.ts | 4 +-- src/app/v1/load-by-tile.ts | 2 +- 7 files changed, 53 insertions(+), 17 deletions(-) diff --git a/example/common.js b/example/common.js index dd6aa66..b6d924c 100644 --- a/example/common.js +++ b/example/common.js @@ -15,7 +15,7 @@ const BOUNDS = [ [53.20890963521473, 25.52765018907181], [57.444403818421854, 24.71096299361919] ]; -const ZOOM_RANGE = {min: 4, max: 10}; +const ZOOM_RANGE = {min: 4, max: 19}; const LOCATION = {bounds: BOUNDS}; const TILE_SIZE = 256; const TEST_TILE_SERVER = 'https://mappable-test-server-d7778c5d7460.herokuapp.com'; @@ -46,9 +46,9 @@ function makeEntity(map, feature) { { id: feature.id, coordinates: feature.geometry.coordinates, - onDoubleClick: () => { - if (feature.properties.minMax > 1) { - map.setLocation(feature.properties.minMax); + onDoubleClick: (e) => { + if (feature.properties.minMax) { + map.setLocation({bounds: feature.properties.minMax, duration: 400}); } } }, @@ -109,7 +109,7 @@ async function fetchBound([[lng1, lat1], [lng2, lat2]]) { controller = new AbortController(); const signal = controller.signal; - const data = await fetch(`${TEST_TILE_SERVER}/v1/${MODE}?lng1=${lng1}&lat1=${lat1}&lng2=${lng2}&lat2=${lat2}`, { + const data = await fetch(`${TEST_TILE_SERVER}/v1/${MODE}?lng1=${lng1}&lat1=${lat1}&lng2=${lng2}&lat2=${lat2}&limit=10000`, { signal }).then((resp) => resp.json()); @@ -120,3 +120,18 @@ async function fetchBound([[lng1, lat1], [lng2, lat2]]) { return features; } + +const layerId = "A"; +const dataSource = { + type: layerId, + fetchTile: (x, y, z) => { + const canvas = document.createElement("canvas"); + canvas.width = TILE_SIZE; + canvas.height = TILE_SIZE; + const ctx = canvas.getContext("2d"); + ctx.strokeStyle = "#010101"; + ctx.strokeRect(0, 0, TILE_SIZE, TILE_SIZE); + ctx.fillText(`${x}-${y}-${z}`, 10, 15); + return Promise.resolve({ image: canvas }); + } +} diff --git a/example/vanilla.html b/example/vanilla.html index 59f5ce8..6734854 100644 --- a/example/vanilla.html +++ b/example/vanilla.html @@ -30,17 +30,36 @@ MMapListener, MMapControls, MMapCollection, - MMapMarker + MMapTileDataSource, + MMapLayer } = mappable; const {MMapZoomControl} = await mappable.import('@mappable-world/mappable-controls@0.0.1'); const {MMapEntityTileLoader} = await mappable.import('@mappable-world/mappable-entity-tile-loader'); - map = new MMap(document.getElementById('app'), {location: LOCATION, zoomRange: ZOOM_RANGE}); + map = new MMap(document.getElementById('app'), { + location: LOCATION, + behaviors: [ + 'drag', + 'pinchZoom', + 'scrollZoom', + 'magnifier', + 'oneFingerZoom', + 'mouseRotate', + 'mouseTilt', + 'pinchRotate', + 'panTilt' + ], + zoomRange: ZOOM_RANGE + }); map.addChild(new MMapDefaultSchemeLayer()); map.addChild(new MMapDefaultFeaturesLayer()); map.addChild(new MMapControls({position: 'right'}).addChild(new MMapZoomControl({}))); + map.addChild(new MMapTileDataSource({id: layerId, raster: dataSource})).addChild( + new MMapLayer({id: layerId, source: layerId, type: layerId}) + ); + if (MODE !== 'bbox') { map.addChild( new MMapEntityTileLoader({ @@ -112,9 +131,11 @@