Javascript 向传单中的featureLayer添加IF语句

Javascript 向传单中的featureLayer添加IF语句,javascript,json,leaflet,geojson,Javascript,Json,Leaflet,Geojson,我正试图根据用户登录到该站点的电子邮件过滤哪些功能被绘制到地图上。到目前为止,我已经尝试了多种选择,但总是被难倒。这是我目前拥有的代码。请帮忙 以下是错误:未捕获的TypeError:无法读取e.addLayer(laople.js:6)的Object.stamp(laople.js:6)处未定义的属性“\u-laople\u-id”;e.initialize(laople.js:6)的属性“\u-laople\u-id”;app.js:810的Object.o.map(laople.js:6)

我正试图根据用户登录到该站点的电子邮件过滤哪些功能被绘制到地图上。到目前为止,我已经尝试了多种选择,但总是被难倒。这是我目前拥有的代码。请帮忙


以下是错误:未捕获的TypeError:无法读取e.addLayer(laople.js:6)的Object.stamp(laople.js:6)处未定义的属性“\u-laople\u-id”;e.initialize(laople.js:6)的属性“\u-laople\u-id”;app.js:810的Object.o.map(laople.js:6)处未定义的属性“\u-laople.js:6”

var userEmail = $("#email").val();

    if (userEmail.includes("fibertel")) {
      var featureLayer = L.geoJson(null, {
        filter: function(feature, layer) {
          if (feature.properties.contractor === "FiberTel") return true;
        },
        pointToLayer: function (feature, latlng) {
          return L.marker(latlng, {
            title: feature.properties["status_title_github"],
            riseOnHover: true,
            icon: L.icon({
              iconUrl: "assets/pictures/markers/cb0d0c.png",
              iconSize: [30, 40],
              iconAnchor: [15, 32]
            })
          });
        },
        onEachFeature: function (feature, layer) {
          if (feature.properties) {
            layer.on({
              click: function (e) {
                identifyFeature(L.stamp(layer));
                highlightLayer.clearLayers();
                highlightLayer.addData(featureLayer.getLayer(L.stamp(layer)).toGeoJSON());
              },
              mouseover: function (e) {
                if (config.hoverProperty) {
                  $(".info-control").html(feature.properties[config.hoverProperty]);
                  $(".info-control").show();
                }
              },
              mouseout: function (e) {
                $(".info-control").hide();
              }
            });
            if (feature.properties["marker-color"]) {
              layer.setIcon(
                L.icon({
                  iconUrl: "assets/pictures/markers/" + feature.properties["marker-color"].replace("#",'').toLowerCase() + ".png",
                  iconSize: [30, 40],
                  iconAnchor: [15, 32]
                })
              );
            }
          }
        }
      });
    } else if

虽然未进行优化,但您的
if
/
else if
看起来正在实现您想要实现的目标。然后,您需要将数据添加到
featureLayer
(实际上是一个传单GeoJSON图层组)中。如果您需要帮助,请解释什么不起作用,共享潜在的错误消息,添加示例数据和相关代码。您所说的未优化是什么意思?你是说使用函数()?我可以,但是,所有其他涉及featureLayer的编码都必须修复,我现在不想担心这个问题。我想先看到它工作。错误是:未捕获类型错误:无法在e.addLayer(lapper.js:6)的e.addLayer(lapper.js:6)的e.initialize(lapper.js:6)的e.o.map(lapper.js:6)的新e(lapper.js:6)的e.initialize(lapper.js:6)中读取未定义的属性“\u-lapper\u-id”在app.js:810,我有addData代码,你应该在这里编辑你的问题以包含错误堆栈跟踪。它能更好地解释你的问题,所以人们能够帮助你解决它是很重要的。