-2
我是新來的地理位置,我使用PHP。我想在我的網站上獲得一張地圖,網站上的某個人知道他的確切位置。他也應該能夠像在swiggy.com那樣改變他在地圖上的位置如何使用谷歌地圖選擇我的地理位置
我是新來的地理位置,我使用PHP。我想在我的網站上獲得一張地圖,網站上的某個人知道他的確切位置。他也應該能夠像在swiggy.com那樣改變他在地圖上的位置如何使用谷歌地圖選擇我的地理位置
好的,我會假設你已經閱讀過Google Map API文檔。谷歌搜索你問應該在這裏開車你:
https://developers.google.com/maps/articles/geolocation
我要什麼告訴你是如何添加拖動的標記。
var map = new google.maps.Map([...])
//After using geolocation and getting the user coordinates
var marker = new google.maps.Marker({
//Note this variable contains the previously created LatLng Object
//with the user position
position: userPosLatLng,
//Important so the user can realocate
draggable: true,
map: map,
title: 'You're here'
});
想要在用戶停止拖動標記時更新用戶座標嗎?
在這裏你做到了。在前面的行之後添加此事件監聽器:
google.maps.event.addListener(marker, 'dragend', function(event) {
userPosLatLng = event.latLng;
});
請發佈代碼,顯示您迄今嘗試過的代碼。 [如何問](http://stackoverflow.com/help/how-to-ask) –