Got odpowiedź następująco:
// To jest oparte na „punkcie algorytmu wielokąta”
function getPoint() {
float x=-89.82421875; //x and y represents the lat and lng values
float y= 40.18307014852533;
var a = boundaries; //the coordinates used to draw the map
for (i = 0; i < a.features.length; i++) {
PointInPolygon(x,y, a.features[i].geometry.coordinates[0], i);
}
};
function PointInPolygon(pointX, pointY, _vertices, number) {
var j = _vertices.length - 1;
var oddNodes = false;
var polyX, polyY,polyXJ,polyYJ;
for (var i = 0; i < _vertices.length; i++) {
polyY = parseFloat(_vertices[i].toString().split(",")[1]);
polyX = parseFloat(_vertices[i].toString().split(",")[0]);
polyXJ = parseFloat(_vertices[j].toString().split(",")[0]);
polyYJ = parseFloat(_vertices[j].toString().split(",")[1]);
if (polyY < pointY && polyYJ >= pointY ||
polyYJ < pointY && polyY >= pointY) {
if (polyX +
(pointY - polyY)/(polyYJ - polyY) * (polyXJ - polyX) < pointX)
{
oddNodes = !oddNodes;
}
}
j = i;
}
if (oddNodes == true) {
map._layers[number+1].fire('click'); //fire the map click event
}
}
trzeba dać wartość łac i LNG dla wielokąta shape.if dajesz jeden łac LNG wartość będzie ll represnt dot.while dając więcej lat lng narysować wielokąta.Rozpoczęcie i zakończenie lat lng powinny być takie same. – tamilmani
Tak, wyszukaj algorytm geodezyjnego punktu w wielokącie (PIP). – pp19dd
Mam mapę narysowaną za pomocą pewnego zestawu wartości lat i lng. Ale teraz chcę znać identyfikator wielokąta z jednego zestawu wartości lat i lng. – Sudha