12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>基础地图</title>
- <link rel="stylesheet" href="../dist/ol/ol.css" />
- <script src="../dist/index.js"></script>
- <style>*{padding:0;margin:0;}</style>
- </head>
- <body>
- <div id="map" style="height: 100vh; width: 100vw;"></div>
- </body>
- <script>
- const source = new CTMapOl.source.XYZ({
- url: 'http://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=86db5390161c4da2abe96c3fca00f403'
- })
- const tileLayer = new CTMapOl.layer.Tile({
- title: '天地图',
- source: source
- })
- var sourceMarker = new CTMapOl.source.XYZ({
- url: 'http://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=86db5390161c4da2abe96c3fca00f403'
- })
- const tileMarker = new CTMapOl.layer.Tile({
- title: '标注图层',
- source: sourceMarker
- })
- const map = new CTMapOl.Map({
- view: new CTMapOl.View({
- projection: 'EPSG:3857',
- center: CTMapOl.extend.formatLayer.transCooordinateToOpenlayer([116.39, 39.91]),
- // center: [0, 0],
- zoom: 16,
- maxZoom: 18,
- minZoom: 1
- }),
- layers: [tileLayer, tileMarker],
- target: 'map'
- })
- </script>
- </html>
|