A look at Queue.js and how you can load multiple files before running the rest of the code. Simple visualization of populated places in the USA. Files loaded:
- US States - topojson
- Populated Places - geojson
| var countries = {"type":"FeatureCollection","features":[ | |
| {"type":"Feature","id":"AFG","properties":{"name":"Afghanistan"},"geometry":{"type":"Polygon","coordinates":[[[61.210817,35.650072],[62.230651,35.270664],[62.984662,35.404041],[63.193538,35.857166],[63.982896,36.007957],[64.546479,36.312073],[64.746105,37.111818],[65.588948,37.305217],[65.745631,37.661164],[66.217385,37.39379],[66.518607,37.362784],[67.075782,37.356144],[67.83,37.144994],[68.135562,37.023115],[68.859446,37.344336],[69.196273,37.151144],[69.518785,37.608997],[70.116578,37.588223],[70.270574,37.735165],[70.376304,38.138396],[70.806821,38.486282],[71.348131,38.258905],[71.239404,37.953265],[71.541918,37.905774],[71.448693,37.065645],[71.844638,36.738171],[72.193041,36.948288],[72.63689,37.047558],[73.260056,37.495257],[73.948696,37.421566],[74.980002,37.41999],[75.158028,37.133031],[74.575893,37.020841],[74.067552,36.836176],[72.920025,36.720007],[71.846292,36.509942],[71.262348,36.074388],[71.498768,35.650563],[71.613076,35.153203],[71.11 |
A look at Queue.js and how you can load multiple files before running the rest of the code. Simple visualization of populated places in the USA. Files loaded:
Showing the functionality of toggling layers in Leaflet while preserving their reference for later usage (i.e. turning the layer back on). This is useful when working with many layers in leaflet and turning opacity to 0 won't cut it because it can have negative effects when hover and click events require properly layered DOM elements.
Important takeaways:
removeLayer() method.addLayer() method.Good for acting on specific pieces of your SVG object instead of just link as an <img> you can bring the entire object into your HTML. You need two things:
.php - e.g. logo.svg.phpget_template_part<?php
get_template_part( 'includes/partials/logo', 'logo.svg' );
?>| /* Gallery styles available to add to your style.css */ | |
| .gallery {} | |
| a.gallery-image {} | |
| a.gallery-image img {} |
This example shows how geometries with inner loops and outer loops build themselves in opposite direction. The outer loop (red) builds clockwise, while the inner loop (blue) builds counter-clockwise. This is important in order to confidently account for negative MultiPolygons instead of separate Polygon features. Here's a good summary of the importance in winding order.
| var geojson = {}; | |
| geojson['type'] = 'FeatureCollection'; | |
| geojson['features'] = []; | |
| for (var k in data) { | |
| var newFeature = { | |
| "type": "Feature", | |
| "geometry": { | |
| "type": "Point", | |
| "coordinates": [parseFloat(data[k].lng), parseFloat(data[k].lon)] |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script> | |
| <style> | |
| body { | |
| background: MediumAquaMarine; | |
| } |
| var fs = require('fs'); | |
| var map = new mapnik.Map(256, 256), | |
| img = new mapnik.Image(256, 256), | |
| data = fs.readFileSync('/path/to/data.shp'), | |
| vectortile = new mapnik.VectorTile(0,0,0); | |
| // add shapefile to vector tile | |
| vectortile.addData(data, function(err) { | |
| if (err) throw err; |