controler_navigation.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  8. <title data-i18n="resources.title_navigation"></title>
  9. </head>
  10. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  11. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  12. <script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
  13. <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, layerWorld;
  17. var url = host + "/iserver/services/map-world/rest/maps/World";
  18. map = new SuperMap.Map("map", {
  19. controls: [ //初始化Map类,添加控件到map
  20. new SuperMap.Control.Navigation({
  21. dragPanOptions: { //传给 DragPan 控件的属性
  22. enableKinetic: true //设置使用拖拽动画,默认为false
  23. },
  24. autoActivate: true, //添加到地图的控件是否自动生效,默认为true
  25. documentDrag: true, //允许拖拽地图,使地图能够平移到视图窗口外。默认为false
  26. handleRightClicks: true, //是否响应右键点击,默认为false
  27. //zoomBoxEnabled:false, //是否允许用户绘制缩放框,默认为true
  28. zoomBoxKeyMask: 4, //同时按下Alt时绘制缩放框,默认为SuperMap.Handler.MOD_SHIFT,默认值为1
  29. //zoomWheelEnabled:false, //是否允许用户滑动鼠标滚轴缩放地图,默认为true
  30. pinchZoomOptions: { //传给 PinchZoom 控件的属性
  31. autoActivate: false //将该类添加到地图上时,自动激活该控件,默认为true
  32. }
  33. })], allOverlays: true
  34. },notice());
  35. function notice() {
  36. widgets.alert.showAlert(resources.msg_navigation,true,300,false,0.8);
  37. }
  38. layerWorld = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, {
  39. transparent: true,
  40. cacheEnabled: true
  41. }, {maxResolution: "auto"}); //获取图层服务地址
  42. layerWorld.events.on({"layerInitialized": addLayer});
  43. //将地图加入map
  44. function addLayer() {
  45. map.addLayer(layerWorld);
  46. map.setCenter(new SuperMap.LonLat(0, 0), 2);
  47. }
  48. </script>
  49. </body>
  50. </html>