-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
274 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>User Interactions - Draw tool to draw geometries</title> | ||
<style type="text/css"> | ||
html, | ||
body { | ||
margin: 0px; | ||
height: 100%; | ||
width: 100% | ||
} | ||
|
||
.container { | ||
width: 100%; | ||
height: 100% | ||
} | ||
</style> | ||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/maptalks/dist/maptalks.min.css' /> | ||
<script type='text/javascript' src='https://cdn.jsdelivr.net/npm/maptalks-gl/dist/maptalks-gl.js'></script> | ||
<script type='text/javascript' src='https://unpkg.com/maptalks.tileclip@latest/dist/maptalks.tileclip.js'></script> | ||
|
||
<body> | ||
<div id="map" class="container"></div> | ||
<script> | ||
|
||
const tileActor = maptalks.getTileActor(); | ||
const maskId = '青浦区'; | ||
const roadTileUrl = 'https://wprd04.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=8<ype=11'; | ||
|
||
const baseLayer = new maptalks.TileLayer('base', { | ||
// debug: true, | ||
urlTemplate: "https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}", | ||
subdomains: ["a", "b", "c", "d"], | ||
// bufferPixel: 1 | ||
}) | ||
|
||
baseLayer.on('renderercreate', function (e) { | ||
//load tile image | ||
// img(Image): an Image object | ||
// url(String): the url of the tile | ||
e.renderer.loadTileBitmap = function (url, tile, callback) { | ||
const { x, y, z } = tile; | ||
const urlTemplate = baseLayer.options.urlTemplate; | ||
const maxAvailableZoom = 18; | ||
tileActor.getTileWithMaxZoom({ | ||
x, | ||
y, | ||
z, | ||
urlTemplate: [urlTemplate, roadTileUrl], | ||
maxAvailableZoom, | ||
// filter: 'sepia(100%) invert(90%)' | ||
}).then(imagebitmap => { | ||
callback(imagebitmap); | ||
}).catch(error => { | ||
//do some things | ||
console.error(error); | ||
}) | ||
}; | ||
}); | ||
|
||
var map = new maptalks.Map('map', { | ||
zoomControl: true, | ||
"center": [121.65586045, 31.12453538], "zoom": 18.064897200334302, "pitch": 0, "bearing": 0, | ||
}); | ||
|
||
const sceneConfig = { | ||
postProcess: { | ||
enable: true, | ||
antialias: { enable: true } | ||
} | ||
}; | ||
const groupLayer = new maptalks.GroupGLLayer('group', [], { sceneConfig }); | ||
groupLayer.addTo(map); | ||
|
||
baseLayer.addTo(groupLayer); | ||
|
||
|
||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>User Interactions - Draw tool to draw geometries</title> | ||
<style type="text/css"> | ||
html, | ||
body { | ||
margin: 0px; | ||
height: 100%; | ||
width: 100% | ||
} | ||
|
||
.container { | ||
width: 100%; | ||
height: 100% | ||
} | ||
</style> | ||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/maptalks/dist/maptalks.min.css' /> | ||
<script type='text/javascript' src='https://cdn.jsdelivr.net/npm/maptalks-gl/dist/maptalks-gl.js'></script> | ||
<script type='text/javascript' src='https://unpkg.com/maptalks.tileclip@latest/dist/maptalks.tileclip.js'></script> | ||
|
||
<body> | ||
<div id="map" class="container"></div> | ||
<script> | ||
|
||
const tileActor = maptalks.getTileActor(); | ||
const maskId = '青浦区'; | ||
const roadTileUrl = 'https://wprd04.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=8<ype=11'; | ||
const baseLayer = new maptalks.TileLayer('base', { | ||
// debug: true, | ||
urlTemplate: "https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}", | ||
subdomains: ["a", "b", "c", "d"], | ||
// bufferPixel: 1 | ||
}) | ||
|
||
baseLayer.on('renderercreate', function (e) { | ||
//load tile image | ||
// img(Image): an Image object | ||
// url(String): the url of the tile | ||
e.renderer.loadTileBitmap = function (url, tile, callback) { | ||
const { x, y, z } = tile; | ||
const urlTemplate = baseLayer.options.urlTemplate; | ||
const maxAvailableZoom = 18; | ||
tileActor.getTileWithMaxZoom({ | ||
x, | ||
y, | ||
z, | ||
urlTemplate: [urlTemplate, roadTileUrl], | ||
maxAvailableZoom, | ||
// filter: 'sepia(100%) invert(90%)' | ||
}).then(imagebitmap => { | ||
tileActor.clipTile({ | ||
tile: imagebitmap, | ||
tileBBOX: baseLayer._getTileBBox(tile), | ||
projection: baseLayer.getProjection().code, | ||
tileSize: baseLayer.getTileSize().width, | ||
maskId, | ||
}).then(image => { | ||
callback(image); | ||
}).catch(error => { | ||
//do some things | ||
console.error(error); | ||
}) | ||
}).catch(error => { | ||
//do some things | ||
console.error(error); | ||
}) | ||
}; | ||
}); | ||
|
||
var map = new maptalks.Map('map', { | ||
zoomControl: true, | ||
"center": [121.65586045, 31.12453538], "zoom": 9.064897200334302, "pitch": 0, "bearing": 0, | ||
}); | ||
|
||
const sceneConfig = { | ||
postProcess: { | ||
enable: true, | ||
antialias: { enable: true } | ||
} | ||
}; | ||
const groupLayer = new maptalks.GroupGLLayer('group', [], { sceneConfig }); | ||
groupLayer.addTo(map); | ||
|
||
const layer = new maptalks.VectorLayer('layer').addTo(map); | ||
|
||
const symbol = { | ||
polygonOpacity: 0, | ||
lineColor: 'red' | ||
} | ||
|
||
|
||
// baseLayer.addTo(groupLayer); | ||
|
||
fetch('./青浦区-holes.geojson').then(res => res.json()).then(geojson => { | ||
const polygons = maptalks.GeoJSON.toGeometry(geojson, (geo => { | ||
geo.setSymbol(symbol); | ||
})); | ||
layer.addGeometry(polygons); | ||
map.setView({ | ||
"center":[120.9813688,31.06587294],"zoom":19.516412543204773,"pitch":0,"bearing":0 | ||
}) | ||
tileActor.injectMask(maskId, geojson.features[0]).then(data => { | ||
baseLayer.addTo(groupLayer); | ||
}).catch(error => { | ||
console.error(error); | ||
}) | ||
}) | ||
|
||
|
||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>User Interactions - Draw tool to draw geometries</title> | ||
<style type="text/css"> | ||
html, | ||
body { | ||
margin: 0px; | ||
height: 100%; | ||
width: 100% | ||
} | ||
|
||
.container { | ||
width: 100%; | ||
height: 100% | ||
} | ||
</style> | ||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/maptalks/dist/maptalks.min.css' /> | ||
<script type='text/javascript' src='https://cdn.jsdelivr.net/npm/maptalks-gl/dist/maptalks-gl.js'></script> | ||
<script type='text/javascript' src='https://unpkg.com/maptalks.tileclip@latest/dist/maptalks.tileclip.js'></script> | ||
<body> | ||
<div id="map" class="container"></div> | ||
<script> | ||
|
||
const tileActor = maptalks.getTileActor(); | ||
const maskId = '青浦区'; | ||
|
||
const roadTileUrl = 'https://wprd04.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=8<ype=11'; | ||
|
||
const baseLayer = new maptalks.TileLayer('base', { | ||
// debug: true, | ||
urlTemplate: "https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}", | ||
subdomains: ["a", "b", "c", "d"], | ||
// bufferPixel: 1 | ||
}) | ||
|
||
baseLayer.on('renderercreate', function (e) { | ||
//load tile image | ||
// img(Image): an Image object | ||
// url(String): the url of the tile | ||
e.renderer.loadTileBitmap = function (url, tile, callback) { | ||
const { x, y, z } = tile; | ||
const url1 = roadTileUrl.replace("{x}", x).replace('{y}', y).replace('{z}', z); | ||
tileActor.getTile({ | ||
url: [url, url1].map(url => { | ||
return maptalks.Util.getAbsoluteURL(url) | ||
}) | ||
}).then(imagebitmap => { | ||
callback(imagebitmap); | ||
}).catch(error => { | ||
//do some things | ||
console.error(error); | ||
}) | ||
}; | ||
}); | ||
|
||
var map = new maptalks.Map('map', { | ||
"center": [121.65586045, 31.12453538], "zoom": 9.064897200334302, "pitch": 0, "bearing": 0, | ||
}); | ||
|
||
const sceneConfig = { | ||
postProcess: { | ||
enable: true, | ||
antialias: { enable: true } | ||
} | ||
}; | ||
const groupLayer = new maptalks.GroupGLLayer('group', [], { sceneConfig }); | ||
groupLayer.addTo(map); | ||
|
||
baseLayer.addTo(groupLayer); | ||
|
||
|
||
</script> | ||
</body> | ||
|
||
</html> |