1
我正在使用Azure移動服務 - NodeJS後端 ,我想檢查包含點的多邊形地圖。 如何使用谷歌地圖庫呢?或者沒有辦法?在Azure移動服務NodeJS中使用google.maps
--Thanks--
var customerLatLng = new google.maps.LatLng(lat, lng);
var area = serviceParsed[0];
/*example: [{"type":"POLYGON","id":null,"geometry":[[[21.070767653166016,105.80863952636719],[21.01180841534327,105.77705383300781],[21.031036817912042,105.87455749511719]]]}] */
var triangleCoords = [];
if (area.type == "POLYGON") {
for (var j = 0; j < area.geometry[0].length; j++) {
triangleCoords.push({
"lat": area.geometry[0][j][0],
"lng": area.geometry[0][j][1]
});
};
} else { }
var bermudaTriangle = new google.maps.Polygon({ paths: triangleCoords });
if (google.maps.geometry.poly.containsLocation(customerLatLng, bermudaTriangle)) {
filteredResults.push(item.Id);
}
只是爲了驗證,您想要在Node後端使用Google Maps SDK嗎?在什麼情況下?你可以發佈一個完整的樣本嗎? –
是的,如上例,我想使用谷歌地圖來檢查多邊形區域是否包含Mobile Services API(Node JS)中的一個點(位置)。 但我收到錯誤「google未定義」 –
要確認,您正在使用Azure移動服務或Azure移動應用程序? –