2 import { refresh_page } from '../lib/stores.js';
4 export let extra_classes = '';
5 export let feature = null;
7 let url_params = new URLSearchParams();
8 let href = 'details.html';
10 function formatShortOSMType(sType) {
11 if (sType === 'node') return 'N';
12 if (sType === 'way') return 'W';
13 if (sType === 'relation') return 'R';
17 function handleClick() {
18 refresh_page('details', url_params);
22 let new_params = new URLSearchParams();
24 if (feature !== null) {
25 if (feature.osm_type) {
26 if (feature.osm_type.length === 1) {
27 new_params.set('osmtype', feature.osm_type);
29 new_params.set('osmtype', formatShortOSMType(feature.osm_type));
32 new_params.set('osmid', feature.osm_id);
35 new_params.set('class', feature.class);
36 } else if (feature.category) {
37 new_params.set('class', feature.category);
39 } else if (feature.place_id) {
40 new_params.set('place_id', feature.place_id);
43 url_params = new_params;
47 let param_str = url_params.toString();
48 href = 'details.html' + (param_str ? '?' : '') + param_str;
52 <a on:click|preventDefault|stopPropagation={handleClick} href={href} class={extra_classes}><slot></slot></a>