我想從JS中導出搜索結果變量(緯度和經度)作爲php變量。 我知道有必要有另一個PHP文件,例如test.php。Google Maps API結果變量到php
變量如下:
marker.setPlace({
placeId: place.place_id,
location: results[0].geometry.location,
});
marker.setVisible(true);
//infowindowContent.children['place-name'].textContent = place.name;
//infowindowContent.children['place-id'].textContent = place.place_id;
infowindowContent.children['place-address'].textContent =
//results[0].formatted_address;
results[0].geometry.location.lat(),
results[0].geometry.location.lng(),
infowindow.open(map, marker);
});
});
}
您需要在PHP中創建HTTP端點,然後您可以將經緯度傳遞給url或者可以設置爲cookie並從PHP中讀取 –