Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 插入google.maps.geometry.poly.containsLocation可减少迭代时间_Ruby On Rails_Google Maps_Google Maps Api 3 - Fatal编程技术网

Ruby on rails 插入google.maps.geometry.poly.containsLocation可减少迭代时间

Ruby on rails 插入google.maps.geometry.poly.containsLocation可减少迭代时间,ruby-on-rails,google-maps,google-maps-api-3,Ruby On Rails,Google Maps,Google Maps Api 3,我正在使用google map containsLocation方法在多边形内部搜索我的标记。我已经有了多边形数据,比如 sogang_a.setMap(map); yonsei_a.setMap(map); yonsei_c.setMap(map); yonsei_e.setMap(map); ewha_yonsei_b.setMap(map); ewha_yonsei_d.setMap(map); ewha_a.setMap(map); 我在我的/map/上呈现来自_hasuk的js

我正在使用google map containsLocation方法在多边形内部搜索我的标记。我已经有了多边形数据,比如

sogang_a.setMap(map);
yonsei_a.setMap(map);
yonsei_c.setMap(map); 
yonsei_e.setMap(map); 
ewha_yonsei_b.setMap(map); 
ewha_yonsei_d.setMap(map);
ewha_a.setMap(map);
我在我的
/map/上呈现来自_hasuk
的json数据,并使用

       $.get("/map/from_hasuk", function(data, status){
         for (var i = 0; i < data.length; i++){

        var infowindow = null;
        var infoWindow = new google.maps.InfoWindow();
        var latlng = new google.maps.LatLng(data[i].lat, data[i].lng);
        if ("<%= @univ %>"== "a") {
          if(google.maps.geometry.poly.containsLocation(latlng, sogang_a) == true ){
                var marker = new google.maps.Marker({
                         position: latlng,
                         map: map
                     });
                marker.setMap(map); 
                }//if
              }//contain location 
           }//univ
         else if("<%= @univ %>"== "b") {

           if (google.maps.geometry.poly.containsLocation(latlng, <%= yonsei_a %>) == true || 
               google.maps.geometry.poly.containsLocation(latlng, <%= yonsei_c %>) == true ||
               google.maps.geometry.poly.containsLocation(latlng, <%= yonsei_e %>) == true ||
               google.maps.geometry.poly.containsLocation(latlng, <%= ewha_yonsei_b %>) == true ||
               google.maps.geometry.poly.containsLocation(latlng, <%= ewha_yonsei_d %>) == true ) {


            var marker = new google.maps.Marker({
                 position: latlng,
                 map: map
             });
          } //else if
      } //for loop
      } //get jquery
减少了迭代时间,这意味着当我在
else if
上设置该条件时,计数时间会减少。例如,我通过put
console.log(“”)检查它
,则结果为


设置条件:8,而不是设置:40。删除其中一个条件:25
。除此之外,一切都很好,不是多边形或短语的问题。我缺少什么?

我终于从漫长而无聊的旅行中找到了解决方案。问题是……没什么!我的意思是,
包含位置的方法很好。我得到了解决方案来自我的事件和其他DOM的警告,它与gmap一起工作。如果有人在寻找与google map JS api的
containLocation
相关的方法,请使用它。谢谢

google.maps.geometry.poly.containsLocation(latlng, <%= ewha_yonsei_b %>) == true ||
google.maps.geometry.poly.containsLocation(latlng, <%= ewha_yonsei_d %>) == true