Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6820077

Browse files
committed
Implement #199
1 parent e0cf49a commit 6820077

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

‎full/app.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,22 @@
195195
196196
modelUpdated(newVal, schema) {
197197
console.log("main model has updated", newVal, schema);
198+
},
199+
200+
201+
getLocation(model) {
202+
if (navigator.geolocation) {
203+
navigator.geolocation.getCurrentPosition((pos) => {
204+
if (!model.address)
205+
model.address = {};
206+
if (!model.address.geo)
207+
model.address.geo = {};
208+
model.address.geo.latitude = pos.coords.latitude.toFixed(5);
209+
model.address.geo.longitude = pos.coords.longitude.toFixed(5);
210+
});
211+
} else {
212+
alert("Geolocation is not supported by this browser.");
213+
}
198214
}
199215
200216

‎full/schema.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,18 +351,7 @@ module.exports = {
351351
classes: "btn-location",
352352
label: "Current location",
353353
onclick: function(model) {
354-
if (navigator.geolocation) {
355-
navigator.geolocation.getCurrentPosition((pos) => {
356-
if (!model.address)
357-
model.address = {};
358-
if (!model.address.geo)
359-
model.address.geo = {};
360-
model.address.geo.latitude = pos.coords.latitude.toFixed(5);
361-
model.address.geo.longitude = pos.coords.longitude.toFixed(5);
362-
});
363-
} else {
364-
alert("Geolocation is not supported by this browser.");
365-
}
354+
return this.$parent.getLocation(model);
366355
}
367356
}, {
368357
classes: "btn-clear",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /