Skip to content

Commit

Permalink
Replaced to Baidu reverse geocoding service
Browse files Browse the repository at this point in the history
  • Loading branch information
kotori-y committed Oct 11, 2021
1 parent 341836a commit 82f3443
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline';img-src * 'self' data:;font-src 'self' data:">
<link rel="apple-touch-icon" href="icon.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
Expand Down
28 changes: 16 additions & 12 deletions src/components/Travel/TravelBody/TravelBodyVisited.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<ul v-if="!isLoading">
<li @click="getPosition()">{{ city }}</li>
</ul>


</div>
</template>

Expand All @@ -24,7 +22,7 @@ export default {
},
mounted() {
const _city = getCookie("currCity")
if (!!_city) {
if (_city) {
this.city = _city
}
},
Expand All @@ -39,21 +37,27 @@ export default {
"lon": position.coords.longitude
}
const AK = "BUxfI8hTtjSxnEAjvn1hL9GLTr1XpYgX"
const LAT = data.lat
const LON = data.lon
const SHA1 = "D9:CC:18:96:A5:EA:64:48:59:B4:1B:71:54:82:D1:3A:FC:C7:F4:8B"
const PACKAGE = "com.travelCard.kotori"
const URL = `https://api.map.baidu.com/reverse_geocoding/v3/?ak=${AK}&output=json&coordtype=wgs84ll&location=${LAT},${LON}&mcode=${SHA1};${PACKAGE}`
axios({
method: "get",
url: `https://nominatim.openstreetmap.org/reverse?format=jsonv2`,
params: data,
url: URL,
}).then(resp => {
let _city = resp.data.address["state_district"]
if (!_city) {
_city = resp.data.address["state"]
}
let _city = resp.data["result"]["addressComponent"]["city"]
that.isLoading = false
that.city = _city
setCookie("currCity", _city)
})
};
setCookie("git rmcurrCity", _city)
}).catch(err => alert(JSON.stringify(err)))
}
function onError(error) {
alert('code: ' + error.code + '\n' +
Expand Down

0 comments on commit 82f3443

Please sign in to comment.