Javascript 如果报表问题不起作用

Javascript 如果报表问题不起作用,javascript,jquery,html,Javascript,Jquery,Html,我试图查看输入的lat和long是否与两种多边形类型中的一种对应,一种是键为Live,另一种是键为Soon,但是我似乎无法写入if语句 因此,如果一个lat+long点位于多边形类型Live中,则结果应为“找到位置并处于活动状态”。如果lat+long点很快位于多边形类型中,则结果应该是找到位置,并且很快就会出现。如果lat+long不在多边形中,则结果应为“未找到位置” 我的if语句有什么错 initGeocompleteControl(map, function (result) {

我试图查看输入的lat和long是否与两种多边形类型中的一种对应,一种是键为Live,另一种是键为Soon,但是我似乎无法写入if语句

因此,如果一个lat+long点位于多边形类型Live中,则结果应为“找到位置并处于活动状态”。如果lat+long点很快位于多边形类型中,则结果应该是找到位置,并且很快就会出现。如果lat+long不在多边形中,则结果应为“未找到位置”

我的if语句有什么错

initGeocompleteControl(map, function (result) {
    map.data.forEach(function (f) {
        if (f.getProperty("key") == "live") {

            var bounds = new google.maps.LatLngBounds();
            calcBounds(f.getGeometry(), bounds);

            if (bounds.contains(result.geometry.location)) {
                $( "#result" ).empty();
                $("#result").html('Location is found and is live');
            } else if (f.getProperty("key") == "soon") {
                var bounds = new google.maps.LatLngBounds();
                calcBounds(f.getGeometry(), bounds);

                if (bounds.contains(result.geometry.location)) {
                    $( "#result" ).empty();
                    $("#result").html('Location is found and is coming soon');
                } else {
                    $( "#result" ).empty();
                    $("#result").html('Location is not found');
                }
              //w11 2ed
            }
          // w10 5nr
        }
    });
});

将else if条件置于外部,即
if(f.getProperty(“key”…

initGeocompleteControl(map, function (result) {
map.data.forEach(function (f) {

    if (f.getProperty("key") == "live") {

        var bounds = new google.maps.LatLngBounds();
        calcBounds(f.getGeometry(), bounds);

        if (bounds.contains(result.geometry.location)) {
            $( "#result" ).empty();
            $("#result").html('Location is found and is live');
        }
        //the else if moved from here
    }
    else if
          (f.getProperty("key") == "soon") {

              var bounds = new google.maps.LatLngBounds();
              calcBounds(f.getGeometry(), bounds);

              if (bounds.contains(result.geometry.location)) {
                  $( "#result" ).empty();
                  $("#result").html('Location is found and is coming soon');
              } 
              //else condition moved from here
          } //and else condition after the else if condtion
          else {
                  $( "#result" ).empty();
                  $("#result").html('Location is not found');
          }
              //w11 2ed

          // w10 5nr
     }); 
}); 

将else if条件置于外部,即
if(f.getProperty(“key”…

initGeocompleteControl(map, function (result) {
map.data.forEach(function (f) {

    if (f.getProperty("key") == "live") {

        var bounds = new google.maps.LatLngBounds();
        calcBounds(f.getGeometry(), bounds);

        if (bounds.contains(result.geometry.location)) {
            $( "#result" ).empty();
            $("#result").html('Location is found and is live');
        }
        //the else if moved from here
    }
    else if
          (f.getProperty("key") == "soon") {

              var bounds = new google.maps.LatLngBounds();
              calcBounds(f.getGeometry(), bounds);

              if (bounds.contains(result.geometry.location)) {
                  $( "#result" ).empty();
                  $("#result").html('Location is found and is coming soon');
              } 
              //else condition moved from here
          } //and else condition after the else if condtion
          else {
                  $( "#result" ).empty();
                  $("#result").html('Location is not found');
          }
              //w11 2ed

          // w10 5nr
     }); 
}); 

哪个
if
语句?您有四个。正确对齐您的代码显示问题;您的
else if(f.getProperty(“key”)==“soon”)
语句太深了一级。请参阅我对您的问题的编辑哪个
if
语句?您有四个。正确对齐您的代码显示问题;您的
else if(f.getProperty(“key”)=“soon”)
语句太深了一级。请参阅我对问题的编辑,因为某些原因,它不会迭代到最后一级。有什么想法为什么?因为某些原因,它不会迭代到最后一级。有什么想法为什么?