123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title data-i18n="resources.title_shadowPopup"></title>
- <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
- <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
- <style type="text/css">
- body {
- margin: 0;
- overflow: hidden;
- background: #fff;
- width: 100%;
- height: 100%
- }
- #map {
- position: absolute;
- width: 100%;
- height: 100%;
- }
- #toolbar {
- position: absolute;
- top: 50px;
- right: 10px;
- width: 300px;
- text-align: center;
- z-index: 100;
- border-radius: 4px;
- }
- </style>
- </head>
- <body>
- <div id="map"></div>
- <script>
- var host = window.isLocal ? window.server : "https://iserver.supermap.io";
- var map, layerWorld, marker, markers, framedCloud, vectorLayer;
- var url = host + "/iserver/services/map-world/rest/maps/World";
- init();
- function init() {
- vectorLayer = new SuperMap.Layer.Vector("Vector Layer");
- //map上添加控件
- map = new SuperMap.Map("map", {
- controls: [
- new SuperMap.Control.ScaleLine(),
- new SuperMap.Control.Zoom(),
- new SuperMap.Control.LayerSwitcher(),
- new SuperMap.Control.Navigation({ //添加导航控件到map
- dragPanOptions: {
- enableKinetic: true //拖拽动画
- }
- })]
- });
- //定义layerWorld图层,获取图层服务地址
- layerWorld = new SuperMap.Layer.TiledDynamicRESTLayer("World", url);
- //为图层初始化完毕添加layerInitialized事件
- layerWorld.events.on({"layerInitialized": addLayer});
- //初始化标记图层类
- markers = new SuperMap.Layer.Markers("Markers");
- size = new SuperMap.Size(21, 25);
- offset = new SuperMap.Pixel(-(size.w / 2), -size.h);
- icon = new SuperMap.Icon('./images/markerbig_select.png', size, offset);
- //初始化标记覆盖物类
- marker = new SuperMap.Marker(new SuperMap.LonLat(-0.1779146, 51.4877081), icon);
- //添加覆盖物到标记图层
- markers.addMarker(marker);
- //注册 click 事件,触发 mouseClickHandler()方法
- marker.events.on({
- "click": mouseClickHandler,
- "touchstart": mouseClickHandler //假如要在移动端的浏览器也实现点击弹框,则在注册touch类事件
- });
- }
- var infowin = null;
- //定义mouseClickHandler函数,触发click事件会调用此函数
- function mouseClickHandler(event) {
- closeInfoWin();
- var contentHTML = "<div style='width:80px; font-size:12px;font-weight:bold ; opacity: 0.8'>";
- contentHTML += resources.text_BeckStreet;
- contentHTML += "</div>";
- //初始化FramedCloud类
- framedCloud = new SuperMap.Popup.FramedCloud(
- "chicken",
- marker.getLonLat(),
- null,
- contentHTML,
- icon,
- true,
- null,
- true
- );
- infowin = framedCloud;
- map.addPopup(framedCloud);
- }
- function closeInfoWin() {
- if (infowin) {
- try {
- infowin.hide();
- infowin.destroy();
- }
- catch (e) {
- }
- }
- }
- //定义addLayer函数,触发 layerInitialized事件会调用此函数
- function addLayer() {
- //map上添加分块动态REST图层和标记图层
- map.addLayers([layerWorld, markers]);
- map.setCenter(new SuperMap.LonLat(0, 50), 4);
- }
- </script>
- </body>
- </html>
|