在LeafletJS中使用WFS图层

在LeafletJS中使用WFS图层

本文介绍了在LeafletJS中使用WFS图层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一个简单的git项目(已删除链接),该项目显示了我如何尝试将Web功能服务(WFS)图层加载到传单中.演示在这里(链接已删除)

I have a simple git project here (link removed) that shows how I'm trying to load web feature service (WFS) layers into leaflet. Demo here (link removed)

当我放大到最大缩放的图层时,我的问题就出现了.应该存在两层(井为蓝色标记,地块为白色多边形).有时包裹会工作,而其他时候它们不会出现.通过将缩放上下切换至最大缩放,您将能够再现结果.

My problem comes when I zoom in to the most zoomed layer. There should be two layers present (wells as blue markers, and land parcels as white polygons). Sometimes the parcels work and other times they don't show up. By toggling the zoom up and down to the maximum zoom, you'll be able to reproduce the results.

有人能看到一种更好的方法,可以同时装载井和地块吗?我的意图是加载更多的WFS层.

Can anybody see a better approach that will allow both the wells and parcels to load? My intention is to load more WFS layers.

推荐答案

问题出现在jsonp回调中-您对所有层使用了相同的函数名,因此,某种形式的数据正在进行覆盖.

Problem is in your jsonp callback - you are using same function name for all layers and as result, there's some kind of overwriting of data going on.

要解决此问题,请使用其他回调名称:

To fix it, use different callback names:

// For citiesDefaultParameters
format_options : 'callback: getJson_cities',

// For wellsDefaultParameters, use
format_options : 'callback: getJson_wells',

// For parcelsDefaultParameters
format_options : 'callback: getJson_parcels',

// In load_wfs function, use:
$.ajax({
    ...
    jsonpCallback: 'getJson_' + name,

这篇关于在LeafletJS中使用WFS图层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 02:22