Skip to content

Instantly share code, notes, and snippets.

js1568 / leaflet-geojson-identify.js
Last active December 20, 2015 11:39
Leaflet Identify function (similar to ESRI ArcGIS Javascript API function) for finding polygons based on a given latlng from in a L.GeoJson feature layer group.Requires Leaflet and geojson-js-utils:
identify: function(latlng) {
var features = new L.FeatureGroup(),
geopoint = {
type: 'Point',
coordinates: [latlng.lng,]
this.eachLayer(function (layer) {
if (gju.pointInPolygon(geopoint, layer.feature.geometry)) {
iwek / find-in-json.js
Created October 20, 2012 21:43
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
ralphcrisostomo / array_dupplicate_counter.js
Created July 19, 2012 07:43
Javascript: Count duplicates in an array
You have a javascript array that likely has some duplicate values and you would like a count of those values.
Try this schnippet out.