欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Openlayers+EasyUI Tree動(dòng)態(tài)實(shí)現(xiàn)圖層控制

 更新時(shí)間:2020年09月28日 11:56:49   作者:零零圈圈  
這篇文章主要為大家詳細(xì)介紹了Openlayers+EasyUI Tree動(dòng)態(tài)實(shí)現(xiàn)圖層控制,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Openlayers+EasyUI Tree動(dòng)態(tài)實(shí)現(xiàn)圖層控制的具體代碼,供大家參考,具體內(nèi)容如下

功能介紹

主要功能

根據(jù)openlayers3.0與easyUI tree 功能實(shí)現(xiàn)圖層顯隱控制功能,達(dá)到子節(jié)點(diǎn)選擇實(shí)現(xiàn)單個(gè)圖層的顯隱,父節(jié)點(diǎn)選擇實(shí)現(xiàn)所有圖層的顯隱。

頁面展示

主要代碼

HTML+CSS

#xuanfu1 {
 position: absolute;
 top: 50px;
 right: 40px;
 background-color: rgba(134,149,237,0.7);
 width: 170px;
 height: 300px;
 z-index: 1;
 }
<div id="main">
 <div id="xuanfu1">
 <ul id="tt" class="easyui-tree" data-options="checkbox:true"></ul> 
 </div>

 <div id="map" style="height: 100%;width:100%;position:relative;background:#ffffff"></div>
</div>

JS

$(document).ready(function () {
 $.ajax({
 url: "TCKZDataQuery",
 success: function (data) {
 var datatrans= JSON.parse(data);
 var dataArr = datatrans.rows;
 CreatTree(dataArr); //創(chuàng)建樹
 AddLayers(dataArr); //添加圖層
 },
 });
 TCKZguanlian(); //樹與圖層控制關(guān)聯(lián)
 })

//-----------創(chuàng)建圖層控制樹----------
 function CreatTree(dataArr) {
 $('#tt').tree({
 data: [{
 id: 1,
 text: '功能圖層',
 state: 'open',

 }, {
 id: 2,
 text: '專題圖層',
 state: 'open',
 children: [{
  id: 21,
  text: '鐵路線',
  checked: true,
 }, {
  id: 22,
  text: '車站',
  checked: true,
 }]
 }, {
 id: 3,
 text: '衛(wèi)星影像',
 checked: true,
 }
 ]
 });
 
 var node = $('#tt').tree('find', 1);
 var nodes = [{ id: '11', text: '繪制圖層', checked: true }];
 if (node) {
 for (i = 0; i < dataArr.length; i++) {
 var kejian;
 if (dataArr[i].VISIBLE == 'true') {
  kejian = true;
 } else {
  kejian = false;
 }
 nodes.push({ id: dataArr[i].ID, text: dataArr[i].TCM, checked: kejian });
 }
 $('#tt').tree('append', {
 parent: node.target,
 data: nodes
 });
 }
 }
//-----------樹與圖層控制關(guān)聯(lián)------------
 function TCKZguanlian(){
 $("#tt").tree({
 onCheck: function (node) {
 var nodechi = $('#tt').tree('find', node.id);
 var nodechildren = $('#tt').tree("getChildren", nodechi.target);

 var AllLayers = map.getLayers().a;
 if (nodechildren == null || nodechildren=='') { //如果為子節(jié)點(diǎn)
  for (i = 0; i < AllLayers.length; i++) {
  var tcname1 = node.text;
  var tcname2 = AllLayers[i].get('title');
  if (tcname1 == tcname2) {
  AllLayers[i].setVisible(node.checked);
  }
  }
 } else {    //如果為父節(jié)點(diǎn)
  for (j = 0; j < nodechildren.length; j++) {
  var tcname1 = nodechildren[j].text;
  for (i = 0; i < AllLayers.length; i++) {
  var tcname2 = AllLayers[i].get('title');
  if (tcname1 == tcname2) {
  AllLayers[i].setVisible(node.checked);
  }
  }
  }
 }
 }
 })
 }

//定義地圖
 var map = new ol.Map({
 controls: ol.control.defaults({
 attribution: false
 }).extend([
 //定義鼠標(biāo)獲取坐標(biāo)控件
 new ol.control.MousePosition({
 projection: 'EPSG:4326',
 coordinateFormat: ol.coordinate.createStringXY(5)//坐標(biāo)精確度
 }),
 new ol.control.OverviewMap(),//縮略圖控件
 new ol.control.ScaleLine(),// 比例尺控件
 new ol.control.ZoomSlider(),// 縮放刻度控件
 ]),
 target: 'map',
 layers: [
 //鐵路線
 new ol.layer.Tile({
 title: '鐵路線', // 定義鐵路線wms地圖,geoserver發(fā)布
 visible: true,
 source: new ol.source.TileWMS({
  url: 'http://127.0.0.1:8085/geoserver/lzjgjt/wms',
  params: {
  'FORMAT': 'image/png',
  'VERSION': '1.1.1',
  tiled: true,
  "LAYERS": 'lzjgjt:xianlu_polyline',
  "exceptions": 'application/vnd.ogc.se_inimage',
  tilesOrigin: 93.408493 + "," + 32.439911
  }
 })
 }),
 //車站
 new ol.layer.Tile({
 title: '車站',
 visible: true,
 source: new ol.source.TileWMS({
  url: 'http://127.0.0.1:8085/geoserver/lzjgjt/wms',
  params: {
  'FORMAT': 'image/png',
  'VERSION': '1.1.1',
  tiled: true,
  "LAYERS": 'lzjgjt:chezhan_point',
  "exceptions": 'application/vnd.ogc.se_inimage',
  tilesOrigin: 93.487889 + "," + 32.441091
  }
 })
 }),
 
 ],
 view: new ol.View({
 center: ol.proj.fromLonLat([104.06684, 34.39373]),
 zoom: 6,
 //限制地圖縮放級(jí)別
 minZoom: 4,
 maxZoom: 16,
 })
 });

C#

#region 圖層控制
 public ActionResult TCKZDataQuery()
 {
 string sql = " select * from TUCENG_DIC t ";
 string jsonData = GetJeJsonData(db.Database.Connection.ConnectionString, sql, Request);
 return Content(jsonData);
 }
 #endregion

圖層數(shù)據(jù)格式

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • JavaScript 使用Ckeditor+Ckfinder文件上傳案例詳解

    JavaScript 使用Ckeditor+Ckfinder文件上傳案例詳解

    這篇文章主要介紹了JavaScript 使用Ckeditor+Ckfinder文件上傳案例詳解,本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • gojs實(shí)現(xiàn)螞蟻線動(dòng)畫效果

    gojs實(shí)現(xiàn)螞蟻線動(dòng)畫效果

    這篇文章介紹了gojs實(shí)現(xiàn)螞蟻線動(dòng)畫效果的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-01-01
  • js+css實(shí)現(xiàn)換膚效果

    js+css實(shí)現(xiàn)換膚效果

    這篇文章主要為大家詳細(xì)介紹了js+css實(shí)現(xiàn)換膚效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • js實(shí)現(xiàn)數(shù)字從零慢慢增加到指定數(shù)字示例

    js實(shí)現(xiàn)數(shù)字從零慢慢增加到指定數(shù)字示例

    今天小編就為大家分享一篇js實(shí)現(xiàn)數(shù)字從零慢慢增加到指定數(shù)字示例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • this,this,再次討論javascript中的this,超全面(經(jīng)典)

    this,this,再次討論javascript中的this,超全面(經(jīng)典)

    在JavaScript中,this 的概念比較復(fù)雜。除了在面向?qū)ο缶幊讨?,this 還是隨處可用的。這篇文章介紹了javascript中的this相關(guān)知識(shí),對javascript this相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧
    2016-01-01
  • JavaScript之Blob對象類型的具體使用方法

    JavaScript之Blob對象類型的具體使用方法

    這篇文章主要介紹了JavaScript之Blob對象類型的具體使用方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • 深入理解JS中的變量及作用域、undefined與null

    深入理解JS中的變量及作用域、undefined與null

    本篇文章主要是對JS中的變量及作用域、undefined與null進(jìn)行了詳細(xì)的介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2014-03-03
  • JavaScript如何讓select選擇框可輸入和可下拉選擇

    JavaScript如何讓select選擇框可輸入和可下拉選擇

    我們知道一般select下拉框是只能選擇的,而有時(shí)我們會(huì)遇到下拉框中沒有要選擇的信息項(xiàng)或者下拉選項(xiàng)特別多時(shí),需要允許用戶輸入想要的內(nèi)容,這篇文章主要給大家介紹了關(guān)于JavaScript如何讓select選擇框可輸入和可下拉選擇的相關(guān)資料,需要的朋友可以參考下
    2023-10-10
  • JS前端開發(fā)之exec()和match()的對比使用

    JS前端開發(fā)之exec()和match()的對比使用

    match()方法可在字符串內(nèi)檢索指定的值,或找到一個(gè)或多個(gè)正則表達(dá)式的匹配,下面這篇文章主要給大家介紹了關(guān)于JS前端開發(fā)之exec()和match()的對比使用的相關(guān)資料,需要的朋友可以參考下
    2022-09-09
  • 微信小程序movable view移動(dòng)圖片和雙指縮放實(shí)例代碼

    微信小程序movable view移動(dòng)圖片和雙指縮放實(shí)例代碼

    movable-area是微信小程序的新組件,可以用來移動(dòng)視圖區(qū)域movable-view。這篇文章主要介紹了微信小程序movable view移動(dòng)圖片和雙指縮放實(shí)例代碼,需要的朋友可以參考下
    2017-08-08

最新評(píng)論