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 && feature.osm_type) {
25 if (feature.osm_type.length === 1) {
26 new_params.set('osmtype', feature.osm_type);
28 new_params.set('osmtype', formatShortOSMType(feature.osm_type));
31 new_params.set('osmid', feature.osm_id);
34 new_params.set('class', feature.class);
35 } else if (feature.category) {
36 new_params.set('class', feature.category);
40 url_params = new_params;
44 let param_str = url_params.toString();
45 href = 'details.html' + (param_str ? '?' : '') + param_str;
49 <a on:click|preventDefault|stopPropagation={handleClick} href={href} class={extra_classes}><slot></slot></a>