aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/express
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/express')
0 files changed, 0 insertions, 0 deletions
18:01:42 -0600 committer secondl1ght <[email protected]> 2022-10-25 18:01:42 -0600 hook up locations map to btc map api and OSM data' href='/coinos-ui.git/commit/src/components/LocationsMap.svelte?h=bigmap&id=aa6debcd83c0b4067e0f8ce9a11d9c9ac02476ad'>aa6debcd ^
a96c96ff ^
cc01d433 ^
a96c96ff ^
225c1f6d ^


























a96c96ff ^




ed2d77d3 ^
a96c96ff ^
225c1f6d ^
fb6345ee ^


1cfc6636 ^
a96c96ff ^
8781f577 ^
f098b90a ^

f45de7f2 ^
1cfc6636 ^

f45de7f2 ^
f45de7f2 ^
225c1f6d ^
f45de7f2 ^
8781f577 ^
1cfc6636 ^
f098b90a ^








00c84349 ^
a6f44759 ^
00c84349 ^

a6f44759 ^
d7e35c5a ^

9cce167a ^


00c84349 ^




d7e35c5a ^
aa6debcd ^
ed2d77d3 ^
aa6debcd ^
ed2d77d3 ^

a96c96ff ^
d7e35c5a ^
















aa6debcd ^
aa6debcd ^
9cce167a ^
aa6debcd ^

225c1f6d ^
aa6debcd ^
21fcf07b ^



2091cf76 ^



















aa6debcd ^
2091cf76 ^










aa6debcd ^






d7e35c5a ^


aa6debcd ^








d7e35c5a ^


aa6debcd ^








d7e35c5a ^


aa6debcd ^
2091cf76 ^

1cfc6636 ^
225c1f6d ^
f45de7f2 ^
a96c96ff ^


4a6ead28 ^
a96c96ff ^

1cfc6636 ^
a96c96ff ^


225c1f6d ^



1cfc6636 ^
225c1f6d ^


225c1f6d ^
a96c96ff ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
        
                             
 
                                                    
                                                   
 


























                                                                        




                              
                                                          
 
                                                 


                                                         
                                                         
 
                                                         

                                                  
                                                              

                                       
                                         
                                             
                                   
                                                   
                     
                                                  








                                                                            
                                                          
 

                                                                   
 

                                                     


                                                                                                




                                                                                    
                          
 
                                                                                                        
                                            

                                                                
 
















                                                                                                                       
 
                                                         
                                                                   

                                                                
                                                                                              
 



                                                                                                                  



















                                                                                                                                                                        
 










                                                                                                                                           






                                                                                                                                               


                                                                                                                 








                                                                                                                                             


                                                                                                                 








                                                                                                                                             


                                                                                                                 
                                                            

                                          
 
                                                  
                           


                 
                                                   

         
                                                                                


                                           



                                   
                                


                                                           
         
        
<script>
	export let locations;

	import { onMount, onDestroy } from 'svelte';
	import { browser } from '$app/environment';

	import html2canvas from 'html2canvas';

	function captureHighResMap(mapElement, scale = 2) {
		// Backup original size
		let originalWidth = mapElement.offsetWidth;
		let originalHeight = mapElement.offsetHeight;

		// Scale the map element
		mapElement.style.transform = `scale(${scale})`;
		mapElement.style.transformOrigin = 'top left';
		mapElement.style.width = originalWidth * scale + 'px';
		mapElement.style.height = originalHeight * scale + 'px';

		return html2canvas(mapElement, {
			width: originalWidth * scale,
			height: originalHeight * scale,
			scale: scale
		}).then((canvas) => {
			// Restore the original size
			mapElement.style.transform = '';
			mapElement.style.width = originalWidth + 'px';
			mapElement.style.height = originalHeight + 'px';

			return canvas;
		});
	}

	let mapElement;
	let map;

	onMount(async () => {
		if (browser) {
			const L = await import('leaflet');

			map = L.map(mapElement, {
				zoomSnap: 0,
				zoomControl: false,
				attributionControl: false
			}).setView([49.26, -123.05], 15);

			const myCustomColour = '#F7931A';

			const markerHtmlStyles = `
			  background-color: ${myCustomColour};
			  width: 9rem;
			  height: 9rem;
			  display: block;
			  position: relative;
        border-radius: 100% 100% 0;
			  transform: rotate(45deg);
        opacity: 0.9;
			  border: 2px solid #000`;

			const icon = L.divIcon({
				className: 'my-custom-pin',
				iconAnchor: [0, 24],
				labelAnchor: [-6, 0],
				popupAnchor: [0, -36],
				html: `<span style="${markerHtmlStyles}" />`
			});

			const mapBounds = map.getBounds();

			const southWest = mapBounds.getSouthWest();
			const northEast = mapBounds.getNorthEast();

			locations = locations.filter(
				(location) =>
					location['osm_json'].tags &&
					location['osm_json'].tags['payment:coinos'] === 'yes' &&
					location['osm_json'].lat &&
					location['osm_json'].lon &&
					location['osm_json'].lat > southWest.lat &&
					location['osm_json'].lat <= northEast.lat &&
					location['osm_json'].lon > southWest.lng &&
					location['osm_json'].lon <= northEast.lng
			);

			L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.png', {
				maxZoom: 18,
				subdomains: ['a', 'b', 'c', 'd']
			}).addTo(map);

			const checkAddress = (location) => {
				if (location['addr:housenumber'] && location['addr:street'] && location['addr:city']) {
					return `${
						location['addr:housenumber'] +
						' ' +
						location['addr:street'] +
						', ' +
						location['addr:city']
					}`;
				} else if (location['addr:street'] && location['addr:city']) {
					return `${location['addr:street'] + ', ' + location['addr:city']}`;
				} else if (location['addr:city']) {
					return `${location['addr:city']}`;
				} else {
					return '';
				}
			};

			locations.forEach((location) => {
				if (location['deleted_at']) return;

				location = location['osm_json'];
				let marker = L.marker([location.lat, location.lon], { icon });

				if (location.tags && location.tags.name) {
					marker.bindTooltip(location.tags.name, { permanent: true }).openTooltip();
				}

				marker.bindPopup(
					`${
						location.tags && location.tags.name
							? `<span class='block'>${location.tags.name}</span>`
							: ''
					}

          <span class='block'>${location.tags && checkAddress(location.tags)}</span>

          ${
						location.tags && location.tags.phone
							? `<a href='tel:${location.tags.phone}' class='block'>${location.tags.phone}</a>`
							: ''
					}

          ${
						location.tags && location.tags.website
							? `<a href=${location.tags.website} target="_blank" rel="noreferrer" class='block'>${location.tags.website}</a>`
							: ''
					}

					${
						location.tags && location.tags['contact:twitter']
							? `<a href=${
									location.tags['contact:twitter'].startsWith('http')
										? location.tags['contact:twitter']
										: `https://twitter.com/${location.tags['contact:twitter']}`
							  } target="_blank" rel="noreferrer" class='block'>TWT: ${
									location.tags['contact:twitter']
							  }</a>`
							: ''
					}

	        ${
						location.tags && location.tags['contact:instagram']
							? `<a href=${
									location.tags['contact:instagram'].startsWith('http')
										? location.tags['contact:instagram']
										: `https://instagram.com/${location.tags['contact:instagram']}`
							  } target="_blank" rel="noreferrer" class='block'>IG: ${
									location.tags['contact:instagram']
							  }</a>`
							: ''
					}

	        ${
						location.tags && location.tags['contact:facebook']
							? `<a href=${
									location.tags['contact:facebook'].startsWith('http')
										? location.tags['contact:facebook']
										: `https://facebook.com/${location.tags['contact:facebook']}`
							  } target="_blank" rel="noreferrer" class='block'>FB: ${
									location.tags['contact:facebook']
							  }</a>`
							: ''
					}

	        ${
						location.tags && location.tags['contact:linkedin']
							? `<a href=${
									location.tags['contact:linkedin'].startsWith('http')
										? location.tags['contact:linkedin']
										: `https://linkedin.com/${location.tags['contact:linkedin']}`
							  } target="_blank" rel="noreferrer" class='block'>LI: ${
									location.tags['contact:linkedin']
							  }</a>`
							: ''
					}`
				);

				marker.addTo(map);
			});
		}
	});

	onDestroy(async () => map && map.remove());
</script>

<div class="mx-auto w-[14043px] h-[9933px] w-full z-0" bind:this={mapElement} />

<style>
	@import 'leaflet/dist/leaflet.css';

	:global(.leaflet-tooltip) {
		border: none;
		border-radius: 4px;
		font-size: 8rem;
		font-weight: bolder;
		color: black;
		background-color: rgba(255, 255, 255, 0.5);
	}
</style>