首页 > 其他分享 >geoserver的GSR插件使用介绍

geoserver的GSR插件使用介绍

时间:2022-12-26 09:58:23浏览次数:75  
标签:map 插件 GSR geoserver var new MapView localhost esri

背景

    GeoServer是一款很好用的开源GIS服务软件,而ArcGIS JS API是一款不错的webgis框架,通常ArcGIS JS API要搭配ArcGIS Server来使用,而ArcGIS Server售价往往过高。

    通过加入GSR扩展,基本正常使用的FeatureServer和MapServer功能。就API而言,每个GeoServer工作区都被视为ArcGIS®服务。ArcGIS®URL在GeoServer中如下所示:

http://localhost:8080/geoserver/gsr/services/topp/MapServer/

http://localhost:8080/geoserver/gsr/services/topp/FeatureServer/

安装方法

    下载GSR Jar包,放到目录里。设置Tomcat跨域。

代码

<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Intro to PopupTemplate - 4.8</title>

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.24/esri/css/main.css">
  <script src="https://js.arcgis.com/4.24/"></script>

  <script>
    require([
      "esri/Map",
      "esri/layers/FeatureLayer",
      "esri/views/MapView",
      "esri/config",
      "dojo/domReady!"
    ], function(
            Map,
            FeatureLayer,
            MapView,esriConfig
    ) {
      esriConfig.request.corsEnabledServers.push("localhost:8080");
      // Create the map
      var map = new Map({
        basemap: "gray-vector",
      });

      // Create the MapView
      var view = new MapView({
        container: "viewDiv",
        map: map,
        extent: { // autocasts as new Extent()
          xmin: 143.83482400000003,
          ymin: -43.648056,
          xmax: 148.47914100000003,
          ymax: -39.573891,
          spatialReference: 4326
        },
      });

      /*************************************************************
       * The PopupTemplate content is the text that appears inside the
       * popup. {fieldName} can be used to reference the value of an
       * attribute of the selected feature. HTML elements can be used
       * to provide structure and styles within the content. The
       * fieldInfos property is an array of objects (each object representing
       * a field) that is use to format number fields and customize field
       * aliases in the popup and legend.
       **************************************************************/

      var template = { // autocasts as new PopupTemplate()
        title: "Boroughs in NY",
        content: [{
          // It is also possible to set the fieldInfos outside of the content
          // directly in the popupTemplate. If no fieldInfos is specifically set
          // in the content, it defaults to whatever may be set within the popupTemplate.
          type: "fields",
          fieldInfos: [ {
            fieldName: "COUNTRY",
            label:"COUNTRY",
            visible: true,
            // format: {
            //   digitSeparator: true,
            //   places: 0
            // }
          }]
        }]
      };

      // Reference the popupTemplate instance in the
      // popupTemplate property of FeatureLayer
      var featureLayer = new FeatureLayer({
        url: "http://localhost:8080/geoserver/gsr/services/topp/FeatureServer/3",
        outFields: ["*"],
        popupTemplate: template
      });
      map.add(featureLayer);
    });

  </script>
</head>

<body>
<div id="viewDiv"></div>
</body>

</html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>MapImageLayer - create dynamic map layers - 4.5</title>

  <link rel="stylesheet" href="https://js.arcgis.com/4.24/esri/css/main.css">
  <script src="https://js.arcgis.com/4.24/"></script>

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>

  <script>
    require(["esri/config"], function (esriConfig) {
      esriConfig.request.corsEnabledServers.push("localhost:8080");
    });
    require([
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/MapImageLayer",
      "esri/config",
      "dojo/domReady!"
    ], function (Map, MapView, MapImageLayer, esriConfig) {
      esriConfig.request.corsEnabledServers.push("localhost:8080");
      var layer = new MapImageLayer({
        url: "http://localhost:8080/geoserver/gsr/services/topp/MapServer/3",
        title: "Topp"
      });

      /*****************************************************************
       * Add the layer to a map
       *****************************************************************/

      var map = new Map({
        basemap: "gray-vector",
        layers: [layer]
      });

      var view = new MapView({
        container: "viewDiv",
        map: map,

        extent: { // autocasts as new Extent()
          xmin: 143.83482400000003,
          ymin: -43.648056,
          xmax: 148.47914100000003,
          ymax: -39.573891,
          spatialReference: 4326
        }
      });
    });
  </script>


</head>

<body>
<div id="viewDiv"></div>

</div>
</body>

</html>

使用效果

11c29201ab9ad48ab5e697b52da0ba0.png

956203feeb088b8d963e8ec744bcf16.png

参考资料

https://www.osgeo.cn/geoserver-user-manual/community/gsr/usage.html

标签:map,插件,GSR,geoserver,var,new,MapView,localhost,esri
From: https://www.cnblogs.com/polong/p/17005032.html

相关文章

  • 14款web前端常用的富文本编辑器插件
    富文本编辑器是一种可内嵌于浏览器,所见即所得的文本编辑器。它提供类似于OfficeWord的编辑功能,方便那些不太懂html用户使用,富文本编辑器的应用非常广泛,它的历史与图文网页......
  • neovim 插件管理
    起因是使用了很久vscode的插件,但是在前几天看到了一个neovim(以下简称nvim)的视频。就看自己的vscode不是很顺眼,感觉界面不够简洁,所以尝试使用nvim。这期间尝试了别人的配......
  • 面试官:你说说 Vue 中的组件和插件有什么区别?
    大家好,我是CoderBin前言面试官:“你说说Vue中的组件和插件有什么区别?”紧张的萌新:“vue组件是封装可复用的UI结构,插件好像是用vue.use()...”面试官:“...”······......
  • VS插件
    LiveServer——浏览器自动刷新安装以下插件安装后,右击插件名,点击扩展设置在输入框中输入custom找到CustomBrowser,设置打开默认浏览器为chrome在html页面中右......
  • leaflet geoserver
    图层的查询条件CQL_FILTER直接通过某个值直接查询列如CQL_FILTER=`region_code=${this.row.regionCode}`​CQL_FILTER='region_codein(xxxx,xxxx,xxxx,xxxx)'......
  • cucumber:使用cucumber-reporting 插件优化HTML report
    承接上一篇:API测试框架:cucumber+springBoot+restAssured原始的cucumberreport比较粗糙,如图下: 我们可以通过cucumber-reporting插件对报告进去优化,集成介绍如下:1)......
  • 常用插件之分布式执行测试用例 pytest-xdist
    原则:用例之间是独立的,用例之间没有依赖关系,用例可以完全独立运行【独立运行】用例执行没有顺序,随机顺序都能正常执行【随机执行】每个用例都能重复运行,运行结果不......
  • Blender必备插件 Node Preview V1.7 材质节点预览插件
    NodePreview是Blender的节点预览缩略图插件,对于可视化编辑非常有用的,也就是说你在编辑节点的时候可以实时的显示出来对于贴图更改的变化,而且还会自动更新,所预览的过程是在......
  • Blender种草植物插件 Graswald Pro 1.3.7
    GraswaldPro在一个附加组件中为您提供最佳的Blender环境创建体验。单击三下即可导入现成的粒子系统。散射更快,控制更多。使用内置的优化方法以获得更高的速度。自定义......
  • uniApp——调整uniApp插件市场上的echarts插件
    前言其实插件市场上的也是基于mpvue-echarts和echarts来的;!>插件中的echarts.js比较大,建议根据实际需求进行定制,然后替换下;uniAppplugin:https://ext.dcloud.net.cn/......