美文网首页
图层相关

图层相关

作者: 扶不起的蝌蚪 | 来源:发表于2020-06-09 15:11 被阅读0次

除特殊注明的HTML结构
默认均为

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Image ArcGIS MapServer</title>
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></script>
    <style>
      .map {
        width: 100%;
        height:400px;
      }
    </style>
  </head>
  <body>
    <div id="map" class="map"></div>
    <script src="index.js"></script>
  </body>
</html>

加载ArcGIS图片图层


var layers =  new ol.layer.Image({
    source: new ImageArcGISRest({
      ratio: 1,
      params: {},
      url: `https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer`
    })
  })
var map = new Map({
  layers: layer,
  target: 'map',
  view: new View({
    center: [-10997148, 4569099],
    zoom: 4
  })
});

[加载ArcGIS瓦片图层]

这种source类型支持地图和图片服务,为了缓存ArcGis服务,但是最好的方式是推荐使用o.source.XYZ

import 'ol/ol.css';
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import {OSM, TileArcGISRest} from 'ol/source';

var url = 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/' +
    'Specialty/ESRI_StateCityHighway_USA/MapServer';

var layers = [
  new TileLayer({
    source: new OSM()
  }),
  new TileLayer({
    extent: [-13884991, 2870341, -7455066, 6338219],
    source: new TileArcGISRest({
      url: url
    })
  })
];
var map = new Map({
  layers: layers,
  target: 'map',
  view: new View({
    center: [-10997148, 4569099],
    zoom: 4
  })
});

图层的显示与隐藏

通过setVisible(Boolean)来控制图层的显示与隐藏

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bing Maps</title>
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></script>
    <style>
      .map {
        width: 100%;
        height:400px;
      }
    </style>
  </head>
  <body>
     <div id="map" class="map"></div>
     <select id="layer-select">
       <option value="Aerial">Aerial</option>
       <option value="AerialWithLabelsOnDemand" selected>Aerial with labels</option>
       <option value="RoadOnDemand">Road</option>
       <option value="CanvasDark">Road dark</option>
       <option value="OrdnanceSurvey">Ordnance Survey</option>
     </select>
    <script src="index.js"></script>
  </body>
</html>
var styles = [
  'RoadOnDemand',
  'Aerial',
  'AerialWithLabelsOnDemand',
  'CanvasDark',
  'OrdnanceSurvey'
];
var layers = [];
for (var i = 0 ; i < styles.length; ++i) {
  layers.push(new TileLayer({
    visible: false,
    preload: Infinity,
    source: new BingMaps({
      key: 'Your Bing Maps Key from http://www.bingmapsportal.com/ here ',
      imagerySet: styles[i]
      // 超过19级的放大后,BING图层会显示为一张标识没有图层的图标,如果为了不显示此效果,你需要最大的放大层级设置为19
      // maxZoom: 19
    })
  }));
}
var map = new Map({
  layers: layers,
  target: 'map',
  view: new View({
    center: [-6655.5402445057125, 6709968.258934638],
    zoom: 13
  })
});

var select = document.getElementById('layer-select');
function onChange() {
//通过遍历匹配与当前选中值相等的图层,使其显示
  for (var i = 0 ; i < layers.length; ++i) {
    layers[i].setVisible(styles[i] === select.value;);
  }
}
select.addEventListener('change', onChange);
//初始化选中的图层
onChange();

相关文章

  • 图层相关

    ⒈添加图层样式 添加图层蒙版 颜色调整 创建新组 创建新图层 删除图层 ⒉把两个图层放到一个组里: ①选择一个图层...

  • 图层相关

    除特殊注明的HTML结构默认均为 加载ArcGIS图片图层 [加载ArcGIS瓦片图层] 这种source类型支持...

  • ps

    、图层应用相关快捷键: 复制图层:Ctrl+j 盖印图层:Ctrl+Alt+Shift+E 向下合并图层:Ctrl...

  • 图层知识,图层相关实用知识

    PS这个软件我从大学时期就开始用,经历了这么多版本,看着它从7.0走到现在,一路摸爬滚打,今天就分享一下PS中,关...

  • 02-选区的布尔运算

    一、相关快捷键 ctrl+shift+alt+N:新建图层 删除图层的方法:1、直接拖拽要删除的图层到图层右下角的...

  • iOS---CoreAnimation

    内容 关于图层动画相关框架的介绍 CoreAnimation结构及图层动画 1. CoreGraphics,Qua...

  • sketch快捷键

    一、画板/图层相关快捷键 1.快速重命名图层:command+R 2.依次选择上一个图层:Shift + Tab(...

  • CoreAnimation(核心动画)概述

    demo 地址 内容 关于图层动画相关框架的介绍 CoreAnimation结构及图层动画 简单demo使用 1....

  • iOS-Core系列框架介绍(一)

    图层、图像相关框架 CoreGraphics(Quartz2D)、QuartzCore(CoreAnimation...

  • AI相关思维导图

    学习的AI相关算法的分类结构:(因为是支付、电商相关行业,所以推荐相关算法在此图层级较高)

网友评论

      本文标题:图层相关

      本文链接:https://www.haomeiwen.com/subject/gtznzhtx.html