123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title data-i18n="resources.title_3tianditu"></title>
- </head>
- <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
- <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
- <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
- <script type="text/javascript" exclude="iclient-classic" include="tianditu" src="../../dist/classic/include-classic.js"></script>
- <script type="text/javascript">
- var map, tiandituLayer, marker, markers, tianMarkerLayer;
- map = new SuperMap.Map("map", {
- controls: [
- new SuperMap.Control.Navigation(),
- new SuperMap.Control.Zoom(),
- new SuperMap.Control.LayerSwitcher()
- ], allOverlays: true
- });
- tiandituLayer = new SuperMap.Layer.WMTS({
- name: "vec",
- url: "https://t0.tianditu.gov.cn/vec_c/wmts?tk=1d109683f4d84198e37a38c442d68311",
- layer: "vec",
- style: "default",
- matrixSet: "c",
- format: "tiles",
- opacity: 1,
- requestEncoding: "KVP"
- });
- tianMarkerLayer = new SuperMap.Layer.WMTS({
- name: "vec",
- url: "https://t0.tianditu.gov.cn/cva_c/wmts?tk=1d109683f4d84198e37a38c442d68311",
- layer: "cva",
- style: "default",
- matrixSet: "c",
- format: "tiles",
- opacity: 1,
- requestEncoding: "KVP"
- });
- tianMarkerLayer.layerType = "cva";
- tianMarkerLayer.isLabel = true;
- map.addControl(new SuperMap.Control.MousePosition());
- markers = new SuperMap.Layer.Markers("Markers");
- map.addLayers([tiandituLayer, markers, tianMarkerLayer]);
- map.setCenter(new SuperMap.LonLat(23, 37), 3);
- addMarker();
- var infowin = null;
- //定义mouseClickHandler函数,触发click事件会调用此函数
- function mouseClickHandler(event) {
- closeInfoWin();
- //初始化popup类
- popup = new SuperMap.Popup(
- "chicken",
- marker.getLonLat(),
- new SuperMap.Size(220, 140),
- '<img src="images/xila.jpg">',
- true,
- null
- );
- infowin = popup;
- //添加弹窗到map图层
- map.addPopup(popup);
- }
- function closeInfoWin() {
- if (infowin) {
- try {
- infowin.hide();
- infowin.destroy();
- }
- catch (e) {
- }
- }
- }
- function addMarker() {
- size = new SuperMap.Size(50, 50);
- offset = new SuperMap.Pixel(-(size.w / 2), -size.h);
- icon = new SuperMap.Icon('../img/markerbig_select.png', size, offset);
- //初始化标记覆盖物类
- marker = new SuperMap.Marker(new SuperMap.LonLat(23.6530190, 37.9439259), icon);
- //添加覆盖物到标记图层
- markers.addMarker(marker);
- //注册 click 事件,触发 mouseClickHandler()方法
- marker.events.on({
- "click": mouseClickHandler,
- "touchstart": mouseClickHandler //假如要在移动端的浏览器也实现点击弹框,则在注册touch类事件
- });
- }
- </script>
- </body>
- </html>
|