怎么样在百度地图里判断一个标注点是否在多边形区域区域?
判断一个标注点是否在多边形区域里
/** * 计算一个点是否在多边形里 * @param {Object} pt 标注点 * @param {Object} poly 多边形数组 */ function isInsidePolygon(pt, poly){ for (var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i) ((poly[i].lat <= pt.lat && pt.lat < poly[j].lat) || (poly[j].lat <= pt.lat && pt.lat < poly[i].lat)) && (pt.lng < (poly[j].lng - poly[i].lng) * (pt.lat - poly[i].lat) / (poly[j].lat - poly[i].lat) + poly[i].lng) && (c = !c); return c; }
本文地址:http://www.45fan.com/a/question/72503.html