123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <!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>
- </head>
- <body style="margin: 0; padding: 0;">
- <!-- <div id="map" style="height: 100vh; width: 100vw"></div> -->
- <div id="mapId" class="mapDIV"></div>
- <div class="input-card4">
- 天地图模糊搜索<br>
- <div><input type="text" id="keyWordQueryRedirect_tdtInput"></div>
- <div class="input-item">
- <button class="btn" onclick="keyWordQuery_tdt()">查询</button>
- </div>
- <div><input type="text" id="keyWordQueryRedirect_tdtOut"></div>
- </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:4326',
- center: [124.6112610521188, 41.530759008113655],
- zoom: 10,
- maxZoom: 18,
- minZoom: 1
- }),
- controls: CTMapOl.control.defaults({
- attribution: false,
- rotate: false,
- zoom: false
- }),
- layers: [tileLayer, tileMarker],
- target: 'mapId'
- })
- function keyWordQuery_tdt() {
- var oBtn = document.getElementById("keyWordQueryRedirect_tdtInput")
- var oIpt = document.getElementById("keyWordQueryRedirect_tdtOut")
- oIpt.value = oBtn.value;
- let ss = CTMapOl.api.keyWordQuery_tdt(map, "沙河");
- ss.then(res => {
- oIpt.value = res.data;
- });
- }
-
- </script>
-
- <style>
- /*地图*/
- .mapDIV {
- height: 100vh;
- width: 100vw;
- z-index: 1;
- }
- .add-switch {
- position: absolute;
- right: 30px;
- height: 68px;
- width: 30px;
- bottom: 112px;
- background: #FFFFFF 100%;
- color: #172537;
- border-radius: 4px;
- display: flex;
- flex-direction: column;
- align-items: center;
- z-index: 2;
- }
- .add-s-block {
- height: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- line-height: 20px;
- font-size: 12px;
- margin-bottom: 2px;
- color: #172537;
- }
-
- .add-zoom {
- width: 20px;
- height: 20px;
- background-image: url('../dist/assets/image/ar/switch/add-zoom.svg');
- background-size: 100% 100%;
- cursor: pointer;
- }
-
- .sub-zoom {
- width: 20px;
- height: 20px;
- background-image: url('../dist/assets/image/ar/switch/sub-zoom.svg');
- background-size: 100% 100%;
- cursor: pointer;
- }
-
- .add-zoom-out {
- width: 20px;
- height: 20px;
- background-image: url('../dist/assets/image/ar/switch/add-zoom-out.svg');
- background-size: 100% 100%;
- }
-
- .sub-zoom-out {
- width: 20px;
- height: 20px;
- background-image: url('../dist/assets/image/ar/switch/sub-zoom-out.svg');
- background-size: 100% 100%;
- }
-
- .add-s-block.btn-click {
- cursor: pointer;
- }
- .input-card {
- position: absolute;
- right: 15px;
- bottom: 15px;
- z-index: 999;
-
- }
-
- .input-card4 {
- position: absolute;
- left: 50px;
- top: 650px;
- z-index: 999;
- }
- </style>
- </html>
|