如何确定标记是否在圆形数组内? [英] How to determine if the markers is inside of the circles array?

查看:56
本文介绍了如何确定标记是否在圆形数组内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我在确定标记是否在圆形数组内部时遇到问题。我提供的代码只能知道一到两个圆圈的标记,而其他人不知道。



Currently i am having problem in determining if the markers is inside of the circle array or not.The code that i have provided manages to know the markers only for one to two circle while the rest does not know.

Quote:

创建圆圈的代码










$.ajax({
            type: "GET",
            url: 'http://localhost:59927//api//Values//FlagingDevice(WithoutParameters)',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (data, status, xhr) {
                for (var i = 0; i < data.Table.length; i++) {
                    circle[i] = L.circle([data.Table[i].Latitude, data.Table[i].Longitude], 50, { color: '#FFFFFF', opacity: 0.5, fillColor: 'white', fillOpacity: .3 }).addTo(map);
                }
            },
            error: function (xhr) {
                alert(xhr.responseText);
            }
        }); 







Quote:

代码确定是否标记在圆圈数组内

The code in determine if the markers is inside the circles array







$.ajax({
                    type: "POST",
                    url: '',
                    data: {
                        Name: value
                    },
                    success: function (data, status, xhr) {
                        for (var s = 0; s < marker1.length; s++) {
                            map.removeLayer(marker1[s]);
                        }
                        for (var i = 0; i < data.length; i++) {
                            var value = i + 1;
    
                            if (circle[i].contains(L.latLng([data[i].Latitude, data[i].Longitude]))) {
                                var customPopup1 = 'Station: ' + data[i].StationName;
    
                                var customOptions1 =
                                {
                                    'maxWidth': '500',
                                    'className': 'custom'
    
                                };
    
                                circle[i].bindPopup(customPopup1, customOptions1);
    
                            }
    
                            else {
                                marker1[i] = L.marker([data[i].Latitude, data[i].Longitude]).addTo(map);
    
                                var customPopup = 'Latitude: ' + data[i].Latitude + '</br>Longitude: ' + data[i].Longitude
                                    + '</br>Station: ' + data[i].StationName + ' </br>Box: ' + data[i].Name + '</br>Timestamp: ' + data[i].LocationSend
                                    + `<br/><a href='/Home/History?DeviceID=${value}'>Click here for Location History</a><br/>`;
    
                                marker1[i].bindPopup(customPopup);
                            }
                         
                        }
                        setTimeout(function () { getCookie("Token", variable); }, 10000);
                        
                    },
                    error: function (xhr) {
                        alert(xhr.responseText);
                    }
                });





我的尝试:



我试图研究解决方案然而无济于事



What I have tried:

I have tried to research for solution however to no avail

推荐答案

.ajax({
type :GET,
url:'http:// localhost:59927 // api //值// FlagingDevice(WithoutParameters)',
contentType:'application / json; charset = utf-8' ,
dataType:'json',
success:function(data,status,xhr){
for(var i = 0; i< data.Table.length; i ++){
circle [i] = L.circle([data.Table [i] .Latitude,data.Table [i] .Longitude],50,{color:'#FFFFFF',opacity:0.5,fillColor:'white ',fillOpacity:.3})。addTo(map);
}
},
错误:function(xhr){
alert(xhr.responseText);
}
});
.ajax({ type: "GET", url: 'http://localhost:59927//api//Values//FlagingDevice(WithoutParameters)', contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (data, status, xhr) { for (var i = 0; i < data.Table.length; i++) { circle[i] = L.circle([data.Table[i].Latitude, data.Table[i].Longitude], 50, { color: '#FFFFFF', opacity: 0.5, fillColor: 'white', fillOpacity: .3 }).addTo(map); } }, error: function (xhr) { alert(xhr.responseText); } });







Quote:

代码确定是否标记在圆圈数组内

The code in determine if the markers is inside the circles array








.ajax({
类型:POST,
url:'',
数据:{
名称:值
},
成功:函数(数据,状态,xhr) ){
for(var s = 0; s< marker1.length; s ++){
map.removeLayer(marker1 [s]);
}
for(var i = 0; i< data.length; i ++){
var value = i + 1;

if(circle [i] .contains(L.latLng([data [i] .Latitude,data [i] .Longitude]))){
var customPopup1 ='Station:'+ data [i] .StationName;

var customOptions1 =
{
'maxWidth':'500',
'className':'custom'

};

circle [i] .bindPopup(customPopup1,customOptions1);

}

else {
marker1 [i] = L.marker([data [i] .Latitude,data [i] .Longitude])。addTo (地图);

var customPopup ='纬度:'+ data [i] .Latitude +'< / br>经度:'+ data [i] .Longitude
+'< / br>站:'+ data [i] .StationName +'< / br> Box:'+ data [i] .Name +'< / br>时间戳:'+ data [i] .LocationSend
+` < br />< a href ='/ Home / History?DeviceID =
.ajax({ type: "POST", url: '', data: { Name: value }, success: function (data, status, xhr) { for (var s = 0; s < marker1.length; s++) { map.removeLayer(marker1[s]); } for (var i = 0; i < data.length; i++) { var value = i + 1; if (circle[i].contains(L.latLng([data[i].Latitude, data[i].Longitude]))) { var customPopup1 = 'Station: ' + data[i].StationName; var customOptions1 = { 'maxWidth': '500', 'className': 'custom' }; circle[i].bindPopup(customPopup1, customOptions1); } else { marker1[i] = L.marker([data[i].Latitude, data[i].Longitude]).addTo(map); var customPopup = 'Latitude: ' + data[i].Latitude + '</br>Longitude: ' + data[i].Longitude + '</br>Station: ' + data[i].StationName + ' </br>Box: ' + data[i].Name + '</br>Timestamp: ' + data[i].LocationSend + `<br/><a href='/Home/History?DeviceID=


{value}'>点击此处查看位置记录< / a>< br /> ;`;

marker1 [i] .bindPopup(customPopup);
}

}
setTimeout(function(){getCookie(Token,variable);},10000);

},
错误:function(xhr){
alert(xhr.responseText);
}
});
{value}'>Click here for Location History</a><br/>`; marker1[i].bindPopup(customPopup); } } setTimeout(function () { getCookie("Token", variable); }, 10000); }, error: function (xhr) { alert(xhr.responseText); } });





我的尝试:



我试图研究解决方案然后无济于事



What I have tried:

I have tried to research for solution however to no avail


这篇关于如何确定标记是否在圆形数组内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆