Improve url format definition
This commit is contained in:
parent
d26cf96c45
commit
9be403c7eb
@ -1,6 +1,21 @@
|
||||
import init from 'xpin-wasm';
|
||||
import * as xpinWasm from 'xpin-wasm';
|
||||
|
||||
export function rustEnumToArray(e) {
|
||||
let ret = [];
|
||||
for (let k in e) {
|
||||
// Add the string coordinate types
|
||||
if (!isNaN(k * 1)) {
|
||||
// This is a numeric key, not a string key
|
||||
// So skip it
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push(k);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
export const WasmStatus = {
|
||||
NotLoaded: -1,
|
||||
Loaded: 0,
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import { getWasm } from '$lib/common.js';
|
||||
import { getWasm, rustEnumToArray } from '$lib/common.js';
|
||||
import { WasmStatus } from '$lib/common.js';
|
||||
import { tick, onMount, onDestroy } from 'svelte';
|
||||
import AddressInput from '$lib/AddressInput.svelte';
|
||||
@ -25,6 +25,17 @@
|
||||
|
||||
let initSuccess = false;
|
||||
let coordinateTypes = [];
|
||||
let urlFormats = [
|
||||
'google_maps',
|
||||
'google_maps_satellite',
|
||||
'geo',
|
||||
'openstreetmap',
|
||||
'waze',
|
||||
'apple_maps',
|
||||
'osmand',
|
||||
'bing_maps',
|
||||
'osmand_direct'
|
||||
];
|
||||
let selectedCoordinateType;
|
||||
let leaflet;
|
||||
import Map from '$lib/Map.svelte';
|
||||
@ -60,15 +71,11 @@
|
||||
await getWasm()
|
||||
.then((w) => {
|
||||
wasm = w;
|
||||
for (let k in wasm.call.CoordinateType) {
|
||||
// Add the string coordinate types
|
||||
if (!isNaN(k * 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
coordinateTypes.push(k);
|
||||
}
|
||||
coordinateTypes = rustEnumToArray(wasm.call.CoordinateType);
|
||||
selectedCoordinateType = coordinateTypes[0];
|
||||
|
||||
console.log('My url formats: ', urlFormats, wasm.call.CoordinateUrls);
|
||||
})
|
||||
.then(async () => {
|
||||
leaflet = await import('leaflet');
|
||||
@ -193,7 +200,7 @@
|
||||
<TabSelector bind:tabInfo />
|
||||
|
||||
{#if tabInfo.selected === 1}
|
||||
<CoordinateInfo bind:coordinateTypes bind:xpin={addr} />
|
||||
<CoordinateInfo bind:coordinateTypes bind:urlFormats bind:xpin={addr} />
|
||||
{/if}
|
||||
{:catch message}
|
||||
<Error {message}>Could not start core module</Error>
|
||||
|
@ -4,17 +4,7 @@
|
||||
|
||||
export let xpin;
|
||||
export let coordinateTypes;
|
||||
|
||||
let urlFormats = [
|
||||
'google_maps',
|
||||
'geo',
|
||||
'openstreetmap',
|
||||
'waze',
|
||||
'apple_maps',
|
||||
'osmand',
|
||||
'bing_maps',
|
||||
'osmand_direct'
|
||||
];
|
||||
export let urlFormats;
|
||||
|
||||
// const shareClicked = (url) => {
|
||||
// if (navigator.share) {
|
||||
|
Loading…
Reference in New Issue
Block a user