Skip to content

Instantly share code, notes, and snippets.

Avatar

Per Liedman perliedman

View GitHub Profile
@perliedman
perliedman / click-through-layers.js
Created Mar 7, 2017
Click through multiple layers of Leaflet VectorGrid
View click-through-layers.js
// Since overlays are VectorGrid layers with canvas rendering,
// they don't support clicking through them (the topmost canvas
// swallows the event, lower layers will not see it).
// We workaround this by this hack (inspired by
// http://www.vinylfox.com/forwarding-mouse-events-through-layers/):
//
// All overlays are in their own Leaflet pane. When a click hits a
// layer in the pane, we first handle the event like normal, and then
// hit the event handler below this comment.
//
View collage.js
function collage(imgUrls, canvas) {
const options = {
margin: 4,
spacing: 2,
borderRadius: 5
}
const ctx = canvas.getContext('2d')
const { width, height } = canvas
const drawWidth = width - 2 * options.margin
View go-kartor-proj4leaflet.html
<!DOCTYPE html>
<html>
<head>
<title>Laserkarta Gbg Norr</title>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.css">
<link rel="stylesheet" href="https://cdn.rawgit.com/ardhi/Leaflet.MousePosition/master/src/L.Control.MousePosition.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet-src.js" type="text/javascript"></script>
@perliedman
perliedman / leaflet-reveal.css
Last active Dec 2, 2019
Embed Leaflet.js maps in Reveal.js presentations
View leaflet-reveal.css
.map {
width: 960px;
height: 480px;
}
.reveal .leaflet-container .leaflet-fade-anim .leaflet-tile, .reveal .leaflet-container .leaflet-fade-anim .leaflet-popup {
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear;
transition: opacity 0.2s linear;
@perliedman
perliedman / OsrmTransportCostsMatrix.java
Last active Mar 26, 2019
OSRM Transport Costs for use with jsprit
View OsrmTransportCostsMatrix.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jsprit.core.problem.Location;
View pouchdb-benchmark.js
var dbName = 'http://localhost:5984/couch-test',
nDocs = 10000,
batchSize = 1000,
scrapFactor = 0,
docs = [],
testQuery = 'entries/sumTime',
destroyDb = false,
_log = console.log,
db;
View leaflet-plugins.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 6 columns, instead of 4. in line 8.
Name,Era,Last commit,URL,Maintainer,Maintainer URL
azgs-leaflet,really old,2012-05-02T00:22:23Z,https://github.com/azgs/azgs-leaflet,AZGS,https://github.com/azgs
RaphaelLayer,0.5,2013-01-17T12:42:48Z,http://dynmeth.github.com/RaphaelLayer/,Dynamic Methods,https://github.com/dynmeth
Leaflet.MultiTileLayer,0.5,2013-02-25T16:34:13Z,https://github.com/mattiasb/Leaflet.MultiTileLayer,Mattias Bengtsson,https://github.com/mattiasb
leaflet.pouch,0.5,2013-04-25T18:01:21Z,https://github.com/calvinmetcalf/leaflet.pouch,Calvin Metcalf,https://github.com/calvinmetcalf/
Leaflet.RevealOSM,0.5,2013-05-28T13:06:41Z,https://github.com/yohanboniface/Leaflet.RevealOSM,Yohan Boniface,http://yohanboniface.me
leaflet.zoomfs,0.6,2013-07-28T19:21:50Z,http://elidupuis.github.com/leaflet.zoomfs,Eli Dupuis,https://github.com/elidupuis
Leaflet.BorderPan,0.6,2013-08-09T01:49:26Z,https://github.com/slara/Leaflet.BorderPan,Sebastián Lara,https://github.com/slara
Leaflet.dbpediaLayer,0.6,2013-09-14T21:51:05Z,https://github.com/kr1/Leaflet.db
View network.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View rankme-stats.txt
perl 0.60 2482
larchii 1.51 2988
Frog's Theme 1.02 2735
jntn 1.13 2617
vico 0.74 2395
arniestone 0.38 2002
ouilly_bob 0.64 2455
ulken 0.91 2512
wishpishh 1.19 2454
mikael.egner 0.25 1130
View round-robin-route-control.js
var RoundRobinPlan = L.Routing.Plan.extend({
initialize: function(waypoints, options) {
L.Routing.Plan.prototype.initialize.call(this, waypoints, options);
},
dragNewWaypoint: function(e) {
var nWps = this._waypoints.length,
insertionIndex = e.afterIndex > nWps - 1 ? 0 : e.afterIndex + 1,
i,
marker,