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