Skip to content

Instantly share code, notes, and snippets.

View kristfal's full-sized avatar

Kristian Fallrø kristfal

View GitHub Profile
@kristfal
kristfal / mapbox-custom-camera.js
Created June 18, 2018 11:09
Mapbox camera snippets
const cameraValid = camera =>
camera && camera.geometry && Array.isArray(camera.geometry.coordinates);
// Workaround for Mapbox issue
// https://github.com/mapbox/react-native-mapbox-gl/issues/1126
export const enforceIntegerPadding = padding =>
padding.map(value => parseInt(value, 10));
export const isValidBounds = camera =>
camera &&
@kristfal
kristfal / xmlToJson.js
Created October 6, 2017 08:07
XML to JSON
function xmlToJson(xml) {
let obj = {};
if (xml.nodeType === 1) {
if (xml.attributes.length > 0) {
obj['@attributes'] = {};
for (let j = 0; j < xml.attributes.length; j++) {
const attribute = xml.attributes.item(j);
obj['@attributes'][attribute.nodeName] = attribute.nodeValue;
}