我想从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中读取 –