当前位置: 首页> 健康> 美食 > 外贸高端网站开发_婚姻咨询律师在线_seo 优化思路_推广吧

外贸高端网站开发_婚姻咨询律师在线_seo 优化思路_推广吧

时间:2025/7/13 22:15:19来源:https://blog.csdn.net/yxlg518/article/details/146919105 浏览次数:1次
外贸高端网站开发_婚姻咨询律师在线_seo 优化思路_推广吧

服务的调用我也测试了网络搜索的很多方法,均未奏效,后来还是通过对官网例子的研究,找到了解决方案,调试的过程是非常痛苦的,最大的问题就是调用后没有任何反应,也不会给你任何的错误信息,这是最郁闷的

最终的解决方式是使用通用的动态图层来实现对geoserver发布的wms服务的调用,首先使用通用动态图层基类创建自定义子类,创建的代码来源于官网示例,直接上代码:

      const CustomWMSLayer = BaseDynamicLayer.createSubclass({properties: {mapUrl: null,mapParameters: null},// Override the getImageUrl() method to generate URL// to an image for a given extent, width, and height.getImageUrl: function (extent, width, height){const urlVariables = this._prepareQuery(this.mapParameters, extent, width, height);const queryString = this._joinUrlVariables(urlVariables);return this.mapUrl + "?" + queryString;},// Prepare query parameters for the URL to an image to be generated_prepareQuery: function (queryParameters, extent, width, height) {const wkid = extent.spatialReference.isWebMercator ? 3857 : extent.spatialReference.wkid;const replacers = {width: width,height: height,wkid: wkid,xmin: extent.xmin,xmax: extent.xmax,ymin: extent.ymin,ymax: extent.ymax};const urlVariables = this._replace({}, queryParameters, replacers);return urlVariables;},// replace the url variables with the application provided values_replace: (urlVariables, queryParameters, replacers) => {Object.keys(queryParameters).forEach((key) => {urlVariables[key] = Object.keys(replacers).reduce((previous, replacerKey) => {return previous.replace("{" + replacerKey + "}", replacers[replacerKey]);}, queryParameters[key]);});return urlVariables;},// join the url parameters_joinUrlVariables: (urlVariables) => {return Object.keys(urlVariables).reduce((previous, key) => {return previous + (previous ? "&" : "") + key + "=" + urlVariables[key];}, "");}});const riverWmsLayer = new CustomWMSLayer({mapUrl: "http://IP:port/路径/wms",mapParameters: {SERVICE: "WMS",REQUEST: "GetMap",FORMAT: "image/png",TRANSPARENT: "TRUE",STYLES: "",VERSION: "1.3.0",LAYERS: "服务里图层名称",WIDTH: "{width}",HEIGHT: "{height}",CRS: "EPSG:{wkid}",BBOX: "{xmin},{ymin},{xmax},{ymax}",token: "token" //如果有就填入,没有就直接把token参数给删掉},//minScale: 20000,title: "地图上图层名字"});

完美调用。

参考:

ArcGIS Maps SDK for JavaScript | Overview | ArcGIS Maps SDK for JavaScript 4.32 | Esri Developer

关键字:外贸高端网站开发_婚姻咨询律师在线_seo 优化思路_推广吧

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: