Skip to content

Instantly share code, notes, and snippets.

View chmartinez's full-sized avatar
💻
Coding when needed

Christian Martínez chmartinez

💻
Coding when needed
View GitHub Profile
@ns-1m
ns-1m / leaflet-button-control.js
Created June 15, 2012 09:07 — forked from ejh/leaflet-button-control.js
Leaflet control button example
// How to use it?
// OnAdd() is called when you use:
// var footButton = new L.Control.Button(footButtonOpts).addTo(map);
// It is passed the map object to which your control is being added.
// The third parameter passed to L.DomEvent.addListener is the context ('this' keyword) which
// you wish to have in the callback (second parameter).
// I still don't know how to use it.
var marker;
var circle;
var map = new L.Map('leaflet', {
dragging: true
});
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/396d41ac26d14f84a7ef6176c59f4720/997/256/{z}/{x}/{y}.png',
cloudmadeAttrib = '',
cloudmade = new L.TileLayer(cloudmadeUrl, {
maxZoom: 18,
attribution: cloudmadeAttrib
@glenrobertson
glenrobertson / EditableCircleMarker.js
Created September 5, 2012 05:17
leaflet editable circle with marker
/*
L.EditableCircleMarker is a marker with a radius
The marker can be moved and the radius can be changed
*/
L.EditableCircleMarker = L.Class.extend({
includes: L.Mixin.Events,
options: {
weight: 1,
@eerohele
eerohele / swaparrayelements.js
Last active November 2, 2021 16:01
Swap two array elements (JavaScript)
/**
* Swap the elements in an array at indexes x and y.
*
* @param (a) The array.
* @param (x) The index of the first element to swap.
* @param (y) The index of the second element to swap.
* @return {Array} The input array with the elements swapped.
*/
var swapArrayElements = function (a, x, y) {
if (a.length === 1) return a;
@lenkan
lenkan / use-location.js
Created March 2, 2019 18:26
React hook that keeps up to date with the current location.
// @ts-check
import { useState, useEffect } from 'react'
function getCurrentLocation () {
return {
pathname: window.location.pathname,
search: window.location.search
}
}