UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

42 lines (41 loc) 1.04 kB
"use strict"; import { NamedFunction0 } from "./_Base"; import { ref } from "@vue/reactivity"; const coordinates = ref({ lng: 0, lat: 0 }); function getCurrentPositionHandler(position) { const { latitude, longitude } = position.coords; coordinates.value.lat = latitude; coordinates.value.lng = longitude; } export class geolocationCurrentPositionRef extends NamedFunction0 { static type() { return "geolocationCurrentPositionRef"; } func() { return coordinates; } } export class geolocationLatitude extends NamedFunction0 { static type() { return "geolocationLatitude"; } func() { return coordinates.value.lat; } } export class geolocationLongitude extends NamedFunction0 { static type() { return "geolocationLongitude"; } func() { return coordinates.value.lng; } } export class geolocationGetCurrentPosition extends NamedFunction0 { static type() { return "geolocationGetCurrentPosition"; } func() { navigator.geolocation.getCurrentPosition(getCurrentPositionHandler); } }