controler_zoomBox.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_zoomBox"></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: [
  20. new SuperMap.Control.Navigation()]
  21. }, notice());
  22. function notice() {
  23. widgets.alert.showAlert(resources.msg_zoomBox,true,300,false,0.8);
  24. }
  25. //初始化拉框缩放控件类
  26. zoombox = new SuperMap.Control.ZoomBox({
  27. keyMask: SuperMap.Handler.MOD_SHIFT, "autoActivate": true //设置keyMask属性,使同时按住Shift绘矩形框
  28. });
  29. //是否将该控件设置为拉框缩小,默认为false,拉框放大
  30. zoombox.out = false;
  31. map.addControl(zoombox);//添加控件
  32. //获取图层服务地址
  33. layerWorld = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, {
  34. transparent: true,
  35. cacheEnabled: true
  36. }, {maxResolution: "auto"});
  37. layerWorld.events.on({"layerInitialized": addLayer});
  38. //添加地图图层、拉框缩放控件到map
  39. function addLayer() {
  40. map.addLayer(layerWorld);
  41. map.setCenter(new SuperMap.LonLat(0, 0), 1);
  42. }
  43. </script>
  44. </body>
  45. </html>