我有一個片段navigator.geolocation.getCurrentPosition在Firefox和Chrome之間返回不同?
navigator.geolocation.getCurrentPosition(function(position) {
// do somehthing
});
,但返回的結果是Chrome和Firefox之間的不同。在鉻中的位置沒有地址屬性。
任何人都可以提供幫助嗎?
感謝
我有一個片段navigator.geolocation.getCurrentPosition在Firefox和Chrome之間返回不同?
navigator.geolocation.getCurrentPosition(function(position) {
// do somehthing
});
,但返回的結果是Chrome和Firefox之間的不同。在鉻中的位置沒有地址屬性。
任何人都可以提供幫助嗎?
感謝
它看起來像Firefox是提前與位置界面曲線的一點。該標準目前不支持地址屬性。
Geolocation API specifications:
中的地位接口是用於通過本API返回的地理位置 信息的容器。規範 的該版本允許一個座標類型屬性和一個時間戳。將來的 API版本可能允許提供其他關於此位置的其他 信息的其他屬性(例如街道地址)。
getCurrentPosition()
方法返回的位置對象包含一個座標屬性和經度和緯度。
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
// do something with lat and lng
});
如果你需要你將不得不使用地理編碼服務的街道地址(如Google Maps Geocoder,這是什麼Firefox is using to find the address)來查找地址。
非常感謝:) – Rocky
在代碼中的其他地方可能有些問題 - 需要查看更多代碼。 – duncan
不,我調試並發現Chrome瀏覽器沒有地址屬性,而Firefox。你可以看到這個快照 https://lh4.googleusercontent.com/-1clzMF9NoFE/TsIeZ5fin8I/AAAAAAAABNo/5VrlvEz2DRw/s833/x.png – Rocky