123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_zoom"></title>
- <script type="text/javascript" src="../js/include-web.js"></script>
- <script type="text/javascript" src="../../dist/ol/include-ol.js"></script>
- </head>
- <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
- <div id="map" style="width: 100%;height:100%"></div>
- <script type="text/javascript">
- var map,
- url = (window.isLocal ? window.server : "https://iserver.supermap.io") + "/iserver/services/map-world/rest/maps/World";
- map = new ol.Map({
- target: 'map',
- controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}),
- view: new ol.View({
- center: [0, 0],
- zoom: 3,
- projection: 'EPSG:4326',
- multiWorld: true
- })
- });
- var ele;
- //禁用双击缩放
- function disableDoubleClickZoom() {
- map.getInteractions().forEach(function (element, index, array) {
- if (element instanceof (ol.interaction.DoubleClickZoom)) {
- ele = element;
- ele.setActive(false);
- }
- });
- }
- //禁用拖动
- function disableDragPan() {
- map.getInteractions().forEach(function (element, index, array) {
- if (element instanceof ol.interaction.DragPan) {
- ele = element;
- ele.setActive(false);
- }
- });
- }
- //禁用鼠标wheel操作
- function disableMouseWheelZoom() {
- map.getInteractions().forEach(function (element, index, array) {
- if (element instanceof ol.interaction.MouseWheelZoom) {
- ele = element;
- ele.setActive(false);
- }
- });
- }
- disableDoubleClickZoom();
- disableDragPan();
- disableMouseWheelZoom();
- var layer = new ol.layer.Tile({
- source: new ol.source.TileSuperMapRest({
- url: url
- }),
- projection: 'EPSG:4326'
- });
- //zoom控件
- zoomControl = new ol.control.Zoom();
- map.addControl(zoomControl);
- //zoomBar控件
- map.addControl(new ol.control.ZoomSlider({}));
- map.addLayer(layer);
- </script>
- </body>
- </html>
|