Created
October 30, 2020 13:41
-
-
Save Natgho/e50fac9e5b2fa35b75b770cc758ed339 to your computer and use it in GitHub Desktop.
QuickApp with HMS Location Kit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import geolocation from '@system.geolocation' | |
import prompt from '@system.prompt'; | |
module.exports = { | |
data: { | |
information: {}, | |
received_data: "", | |
lat: 41.029032, | |
lon: 29.117621 | |
}, | |
onInit() { | |
this.$page.setTitleBar({ | |
text: 'Location Kit Example', | |
textColor: '#ffffff', | |
backgroundColor: '#007DFF', | |
backgroundOpacity: 0.5, | |
menu: true | |
}); | |
}, | |
getGeolocation: function () { | |
var that = this; | |
geolocation.getLocation({ | |
coordType: "wgs84", //It indicates that the geographical location will be returned by invoking the system location ability. | |
timeout: 3000, | |
success: function (ret) { | |
that.lat = ret.latitude; | |
that.lon = ret.longitude; | |
that.received_data += JSON.stringify(ret) + "\n"; | |
console.log('geolocation success---------' + JSON.stringify(ret)); | |
that.getInfo(); | |
}, | |
fail: function (erromsg, errocode) { | |
prompt.showToast({ | |
message: 'geolocation.getLocation----------' + errocode + ': ' + erromsg | |
}) | |
}, | |
complete: function () { | |
console.log('geolocation complete----------') | |
} | |
}) | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment