JS mapping slides
This commit is contained in:
		
							parent
							
								
									1a7eec7baa
								
							
						
					
					
						commit
						b95ebeedf4
					
				
					 6 changed files with 56 additions and 25 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								13.js-mapping/clustering.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								13.js-mapping/clustering.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 381 KiB | 
|  | @ -45,7 +45,7 @@ | ||||||
|         Finland: 5, |         Finland: 5, | ||||||
|         Sweden: 5, |         Sweden: 5, | ||||||
|         Cyprus: 6, |         Cyprus: 6, | ||||||
|         "Czech Republic": 6, |         Czechia: 6, | ||||||
|         Estonia: 6, |         Estonia: 6, | ||||||
|         Hungary: 6, |         Hungary: 6, | ||||||
|         Latvia: 6, |         Latvia: 6, | ||||||
|  | @ -90,10 +90,12 @@ | ||||||
|         .geoMercator() |         .geoMercator() | ||||||
|         //.geoConicEqualArea() |         //.geoConicEqualArea() | ||||||
|         .center([15, 54]) |         .center([15, 54]) | ||||||
|         .scale(600) |         .scale(700) | ||||||
|         .translate([width / 2, height / 2]); |         .translate([width / 2, height / 2]); | ||||||
|       const path = d3.geoPath().projection(projection); |       const path = d3.geoPath().projection(projection); | ||||||
| 
 | 
 | ||||||
|  |       let globalData = null; | ||||||
|  | 
 | ||||||
|       // load TopoJSON |       // load TopoJSON | ||||||
|       d3.json( |       d3.json( | ||||||
|         // DEMO change to 110m/10m |         // DEMO change to 110m/10m | ||||||
|  | @ -106,6 +108,7 @@ | ||||||
|         const europeCountries = geojson.features.filter( |         const europeCountries = geojson.features.filter( | ||||||
|           (d) => euMemberStates[d.properties.name] !== undefined, |           (d) => euMemberStates[d.properties.name] !== undefined, | ||||||
|         ); |         ); | ||||||
|  |         console.log(europeCountries); | ||||||
| 
 | 
 | ||||||
|         svg |         svg | ||||||
|           .selectAll("path") |           .selectAll("path") | ||||||
|  |  | ||||||
|  | @ -42,14 +42,15 @@ https://leafletjs.com/examples.html | ||||||
|       const initialZoom = 12; |       const initialZoom = 12; | ||||||
|       // Leaflet makes a global variable "L" available. |       // Leaflet makes a global variable "L" available. | ||||||
|       // this creates a map in the div above |       // this creates a map in the div above | ||||||
|       const map = L.map("map-goes-here").setView(chicago, initialZoom); |       const map = L.map("map-goes-here"); | ||||||
|  |       map.setView(chicago, initialZoom); | ||||||
| 
 | 
 | ||||||
|       // OSM base layer |       // OSM base layer | ||||||
|       // DEMO change of base layer |       // DEMO change of base layer | ||||||
|       const watercolorURL = |       const watercolorURL = | ||||||
|         "https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg"; |         "https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg"; | ||||||
|       const osmURL = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"; |       const osmURL = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"; | ||||||
|       L.tileLayer(osmURL, { |       L.tileLayer(watercolorURL, { | ||||||
|         maxZoom: 19, |         maxZoom: 19, | ||||||
|         attribution: "© OpenStreetMap contributors", |         attribution: "© OpenStreetMap contributors", | ||||||
|       }).addTo(map); |       }).addTo(map); | ||||||
|  |  | ||||||
|  | @ -67,7 +67,7 @@ | ||||||
|         zoom: 12, |         zoom: 12, | ||||||
|         style: tileJSON, |         style: tileJSON, | ||||||
|         // DEMO toggle style |         // DEMO toggle style | ||||||
|         style: watercolor, |         //style: watercolor, | ||||||
|       }); |       }); | ||||||
| 
 | 
 | ||||||
|       const points = [ |       const points = [ | ||||||
|  |  | ||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -134,11 +134,22 @@ MaplibreGL/MapboxGL are mostly compatible. | ||||||
| - Use library to render map(s) to div(s) on page. | - Use library to render map(s) to div(s) on page. | ||||||
| - Pick base layer, either raster or vector. | - Pick base layer, either raster or vector. | ||||||
|     - If vector, possibly apply additional styling to base. |     - If vector, possibly apply additional styling to base. | ||||||
| - Add additional vector layers based on your data & its features. | - Add additional vector layers based on your data & its features. Do this using methods on the `map` object you got back in the earlier steps. | ||||||
| - Attach event handlers for interactivity on your features and/or input elements adjacent to the map. | - Attach event handlers for interactivity on your features and/or input elements adjacent to the map. | ||||||
| 
 | 
 | ||||||
| --- | --- | ||||||
| 
 | 
 | ||||||
|  | ## Clustering | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | 
 | ||||||
|  | Helps reduce visual clutter and increase performance when there are many points. | ||||||
|  | 
 | ||||||
|  | - <https://github.com/Leaflet/Leaflet.markercluster> | ||||||
|  | - <https://maplibre.org/maplibre-gl-js/docs/examples/cluster/> | ||||||
|  | 
 | ||||||
|  | --- | ||||||
|  | 
 | ||||||
| ## Pop-ups | ## Pop-ups | ||||||
| 
 | 
 | ||||||
| Leaflet/MapLibre offer a simple API for adding pop-ups to features. | Leaflet/MapLibre offer a simple API for adding pop-ups to features. | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue