UNPKG

react-bkoi-gl

Version:

React components for Barikoi GL JS

30 lines 1.08 kB
const skipMethods = ["setMaxBounds", "setMinZoom", "setMaxZoom", "setMinPitch", "setMaxPitch", "setRenderWorldCopies", "setProjection", "setStyle", "addSource", "removeSource", "addLayer", "removeLayer", "setLayerZoomRange", "setFilter", "setPaintProperty", "setLayoutProperty", "setLight", "setTerrain", "setFog", "remove"]; export default function createRef(mapInstance) { if (!mapInstance) { return null; } const map = mapInstance.map; const result = { getMap: () => map }; for (const key of getMethodNames(map)) { if (!(key in result) && !skipMethods.includes(key)) { result[key] = map[key].bind(map); } } return result; } function getMethodNames(obj) { const result = new Set(); let proto = obj; while (proto) { for (const key of Object.getOwnPropertyNames(proto)) { if (key[0] !== "_" && typeof obj[key] === "function" && key !== "fire" && key !== "setEventedParent") { result.add(key); } } proto = Object.getPrototypeOf(proto); } return Array.from(result); } //# sourceMappingURL=create-ref.js.map