]> git.openstreetmap.org Git - nominatim-ui.git/blob - src/components/MapIcon.svelte
Make page choice more svelty (#51)
[nominatim-ui.git] / src / components / MapIcon.svelte
1 <script>
2
3   export let aPlace;
4   import { get_config_value } from '../lib/config_reader.js'
5
6   let sIcon = getIcon(aPlace);
7
8   let title = 'icon for ' + aPlace.category + ' ' + aPlace.type;
9   let url = get_config_value('Images_Base_Url') + sIcon + '.p.20.png';
10
11   function getIcon(aPlace) {
12     // equivalent to PHP Nominatim::ClassTypes::getIcon
13     // covers 83 of 214 available icon filenames, e.g. transport_roundabout_anticlockwise
14     // transport_rental_bicycle or place_of_worship_christian would need more data from
15     // the place.
16     var aIcons = {
17       'boundary:administrative': 'poi_boundary_administrative',
18       'place:city': 'poi_place_city',
19       'place:town': 'poi_place_town',
20       'place:village': 'poi_place_village',
21       'place:hamlet': 'poi_place_village',
22       'place:suburb': 'poi_place_village',
23       'place:locality': 'poi_place_village',
24       'place:airport': 'transport_airport2',
25       'aeroway:aerodrome': 'transport_airport2',
26       'railway:station': 'transport_train_station2',
27       'amenity:place_of_worship': 'place_of_worship_unknown3',
28       'amenity:pub': 'food_pub',
29       'amenity:bar': 'food_bar',
30       'amenity:university': 'education_university',
31       'tourism:museum': 'tourist_museum',
32       'amenity:arts_centre': 'tourist_art_gallery2',
33       'tourism:zoo': 'tourist_zoo',
34       'tourism:theme_park': 'poi_point_of_interest',
35       'tourism:attraction': 'poi_point_of_interest',
36       'leisure:golf_course': 'sport_golf',
37       'historic:castle': 'tourist_castle',
38       'amenity:hospital': 'health_hospital',
39       'amenity:school': 'education_school',
40       'amenity:theatre': 'tourist_theatre',
41       'amenity:library': 'amenity_library',
42       'amenity:fire_station': 'amenity_firestation3',
43       'amenity:police': 'amenity_police2',
44       'amenity:bank': 'money_bank2',
45       'amenity:post_office': 'amenity_post_office',
46       'tourism:hotel': 'accommodation_hotel2',
47       'amenity:cinema': 'tourist_cinema',
48       'tourism:artwork': 'tourist_art_gallery2',
49       'historic:archaeological_site': 'tourist_archaeological2',
50       'amenity:doctors': 'health_doctors',
51       'leisure:sports_centre': 'sport_leisure_centre',
52       'leisure:swimming_pool': 'sport_swimming_outdoor',
53       'shop:supermarket': 'shopping_supermarket',
54       'shop:convenience': 'shopping_convenience',
55       'amenity:restaurant': 'food_restaurant',
56       'amenity:fast_food': 'food_fastfood',
57       'amenity:cafe': 'food_cafe',
58       'tourism:guest_house': 'accommodation_bed_and_breakfast',
59       'amenity:pharmacy': 'health_pharmacy_dispensing',
60       'amenity:fuel': 'transport_fuel',
61       'natural:peak': 'poi_peak',
62       'natural:wood': 'landuse_coniferous_and_deciduous',
63       'shop:bicycle': 'shopping_bicycle',
64       'shop:clothes': 'shopping_clothes',
65       'shop:hairdresser': 'shopping_hairdresser',
66       'shop:doityourself': 'shopping_diy',
67       'shop:estate_agent': 'shopping_estateagent2',
68       'shop:car': 'shopping_car',
69       'shop:garden_centre': 'shopping_garden_centre',
70       'shop:car_repair': 'shopping_car_repair',
71       'shop:bakery': 'shopping_bakery',
72       'shop:butcher': 'shopping_butcher',
73       'shop:apparel': 'shopping_clothes',
74       'shop:laundry': 'shopping_laundrette',
75       'shop:beverages': 'shopping_alcohol',
76       'shop:alcohol': 'shopping_alcohol',
77       'shop:optician': 'health_opticians',
78       'shop:chemist': 'health_pharmacy',
79       'shop:gallery': 'tourist_art_gallery2',
80       'shop:jewelry': 'shopping_jewelry',
81       'tourism:information': 'amenity_information',
82       'historic:ruins': 'tourist_ruin',
83       'amenity:college': 'education_school',
84       'historic:monument': 'tourist_monument',
85       'historic:memorial': 'tourist_monument',
86       'historic:mine': 'poi_mine',
87       'tourism:caravan_site': 'accommodation_caravan_park',
88       'amenity:bus_station': 'transport_bus_station',
89       'amenity:atm': 'money_atm2',
90       'tourism:viewpoint': 'tourist_view_point',
91       'tourism:guesthouse': 'accommodation_bed_and_breakfast',
92       'railway:tram': 'transport_tram_stop',
93       'amenity:courthouse': 'amenity_court',
94       'amenity:recycling': 'amenity_recycling',
95       'amenity:dentist': 'health_dentist',
96       'natural:beach': 'tourist_beach',
97       'railway:tram_stop': 'transport_tram_stop',
98       'amenity:prison': 'amenity_prison',
99       'highway:bus_stop': 'transport_bus_stop2'
100     };
101
102     var sCategoryPlace = aPlace.category + ':' + aPlace.type;
103
104     return aIcons[sCategoryPlace];
105   }
106
107 </script>
108
109 {#if sIcon}
110   <img class="mapicon" src={url} alt={title} />
111 {/if}
112
113 <style>
114   .mapicon {
115     margin: 10px 0;
116   }
117 </style>