diff --git a/dist/bundle.js b/dist/bundle.js index 13930af0..573f316b 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("immutable"),require("mapbox-gl"),require("react")):"function"==typeof define&&define.amd?define(["immutable","mapbox-gl","react"],t):"object"==typeof exports?exports["@urbica/react-map-gl"]=t(require("immutable"),require("mapbox-gl"),require("react")):e["@urbica/react-map-gl"]=t(e.immutable,e["mapbox-gl"],e.react)}(this,function(e,t,r){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var n=r(2);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o(n).default}})},function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(){}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r0&&this.props.onHover(e)}}},{key:"_onClick",value:function(e){if(this.props.onClick){var t=[e.point.x,e.point.y];e.features=this._getFeatures(t,this.props.clickRadius),this.props.onClick(e)}}},{key:"render",value:function(){var e=this,t=this.props,r=t.className,o=t.style;return(0,f.createElement)("div",{ref:function(t){return e._container=t},style:o,className:r})}}]),t}(f.PureComponent);g.displayName="MapGL",g.defaultProps={className:null,mapStyle:"mapbox://styles/mapbox/light-v8",accessToken:null,preserveDrawingBuffer:!1,onViewportChange:null,onClick:null,onHover:null,clickRadius:0,attributionControl:!0,preventStyleDiffing:!1,bearing:0,pitch:0,onLoad:null},t.default=g},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t,r){"use strict";function o(e,t){var r=e.get("sources"),o=t.get("sources"),n=[],i=[],a=[],u=r.keySeq().toArray(),s=o.keySeq().toArray();return u.forEach(function(e){var t=o.get(e);t?t.equals(r.get(e))||i.push({id:e,source:o.get(e)}):a.push({id:e,source:r.get(e)})}),s.forEach(function(e){r.get(e)||n.push({id:e,source:o.get(e)})}),{enter:n,update:i,exit:a}}function n(e,t){var r=e.get("layers"),o=t.get("layers"),n=[],i=[],a={},u={};return o.forEach(function(e,t){var r=e.get("id"),n=o.get(t+1);u[r]={layer:e,id:r,before:n?n.get("id"):null,enter:!0}}),r.forEach(function(e,t){var o=e.get("id"),n=r.get(t+1);a[o]={layer:e,id:o,before:n?n.get("id"):null},u[o]?u[o].enter=!1:i.push(a[o])}),o.reverse().forEach(function(e){var t=e.get("id");a[t]&&a[t].layer.equals(u[t].layer)&&a[t].before===u[t].before||n.push(u[t])}),{updates:n,exiting:i}}function i(e,t){return{sourcesDiff:o(e,t),layersDiff:n(e,t)}}Object.defineProperty(t,"__esModule",{value:!0}),t.diffSources=o,t.diffLayers=n,t.default=i},function(e,t,r){"use strict";function o(e){if(n.Map.isMap(e)){var t=e.get("layers");if(t)return t.filter(function(e){return e.get("interactive")}).map(function(e){return e.get("id")}).toJS()}return[]}Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);t.default=o}])}); //# sourceMappingURL=bundle.js.map \ No newline at end of file diff --git a/dist/bundle.js.map b/dist/bundle.js.map index 8c529858..162b9372 100644 --- a/dist/bundle.js.map +++ b/dist/bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///bundle.js","webpack:///webpack/bootstrap 7fa5850c894d9607d5f1","webpack:///external \"immutable\"","webpack:///./src/index.js","webpack:///./src/components/MapGL.js","webpack:///external \"mapbox-gl\"","webpack:///external \"react\"","webpack:///./src/utils/diff-styles.js","webpack:///./src/utils/style-utils.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_0__","__WEBPACK_EXTERNAL_MODULE_3__","__WEBPACK_EXTERNAL_MODULE_4__","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_interopRequireDefault","obj","default","value","_MapGL","_classCallCheck","instance","Constructor","TypeError","_possibleConstructorReturn","self","ReferenceError","_inherits","subClass","superClass","create","constructor","writable","setPrototypeOf","__proto__","noop","_createClass","defineProperties","target","props","length","descriptor","key","protoProps","staticProps","_mapboxGl","_mapboxGl2","_immutable","_react","_diffStyles2","_diffStyles3","_styleUtils","_styleUtils2","MapGL","_PureComponent","_this","getPrototypeOf","_queryParams","accessToken","supported","componentDidMount","componentWillReceiveProps","componentDidUpdate","_onClick","bind","_onViewportChange","mapStyle","Map","isMap","toJS","map","container","_container","style","center","longitude","latitude","zoom","pitch","bearing","interactive","onViewportChange","attributionControl","preserveDrawingBuffer","canvas","getCanvas","outline","onLoad","once","on","_map","_updateMapViewport","_updateQueryParams","newProps","_updateMapStyle","remove","geometry","parameters","queryParams","layers","queryRenderedFeatures","interactiveLayerIds","update","newSource","source","type","oldSource","getSource","id","oldOpts","workerOptions","undefined","maxzoom","geojsonVtOptions","maxZoom","buffer","tolerance","cluster","clusterRadius","superclusterOptions","radius","clusterMaxZoom","setData","data","removeSource","addSource","prevStyle","nextStyle","styleKeysMap","delete","_this2","prevKeysMap","nextKeysMap","prevKeysList","keys","nextKeysList","some","setStyle","_diffStyles","sourcesDiff","layersDiff","updates","node","layer","enter","forEach","_updateSource","exit","exiting","getLayer","removeLayer","addLayer","before","oldProps","oldMapStyle","preventStyleDiffing","_setDiffStyle","getCenter","lat","lng","getZoom","getPitch","getBearing","flyTo","event","_map$getCenter","viewport","position","bbox","onClick","point","x","y","features","_getFeatures","clickRadius","_this3","_props","className","createElement","ref","_ref","PureComponent","displayName","defaultProps","diffSources","prevSources","nextSources","prevIds","keySeq","toArray","nextIds","nextSource","equals","push","diffLayers","prevLayers","nextLayers","prevMap","nextMap","index","layerImBehind","reverse","diffStyle","getInteractiveLayerIds","filter"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,aAAAA,QAAA,aAAAA,QAAA,UACA,kBAAAC,gBAAAC,IACAD,QAAA,iCAAAJ,GACA,gBAAAC,SACAA,QAAA,wBAAAD,EAAAG,QAAA,aAAAA,QAAA,aAAAA,QAAA,UAEAJ,EAAA,wBAAAC,EAAAD,EAAA,UAAAA,EAAA,aAAAA,EAAA,QACCO,KAAA,SAAAC,EAAAC,EAAAC,GACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAX,OAGA,IAAAC,GAAAW,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAd,WAUA,OANAS,GAAAE,GAAAI,KAAAd,EAAAD,QAAAC,IAAAD,QAAAU,GAGAT,EAAAa,GAAA,EAGAb,EAAAD,QAvBA,GAAAY,KA4DA,OAhCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,SAAAlB,EAAAmB,EAAAC,GACAV,EAAAW,EAAArB,EAAAmB,IACAG,OAAAC,eAAAvB,EAAAmB,GACAK,cAAA,EACAC,YAAA,EAC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I,SAC5B,IAAI6F,EACF,MAAOA,GACJ0G,OAAO,SAAAnN,GAAA,MAAKA,GAAEY,IAAI,iBAClBgE,IAAI,SAAA5E,GAAA,MAAKA,GAAEY,IAAI,QACf+D,OAIP,SR6pBFnE,OAAOC,eAAevB,EAAS,cAC7BsC,OAAO,GQ5qBT,IAAA6B,GAAAzD,EAAA,ERgsBAV,GAAQqC,QQ/qBO2L","file":"bundle.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"immutable\"), require(\"mapbox-gl\"), require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"immutable\", \"mapbox-gl\", \"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@urbica/react-map-gl\"] = factory(require(\"immutable\"), require(\"mapbox-gl\"), require(\"react\"));\n\telse\n\t\troot[\"@urbica/react-map-gl\"] = factory(root[\"immutable\"], root[\"mapbox-gl\"], root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_4__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"immutable\"), require(\"mapbox-gl\"), require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"immutable\", \"mapbox-gl\", \"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@urbica/react-map-gl\"] = factory(require(\"immutable\"), require(\"mapbox-gl\"), require(\"react\"));\n\telse\n\t\troot[\"@urbica/react-map-gl\"] = factory(root[\"immutable\"], root[\"mapbox-gl\"], root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_4__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 1);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_0__;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _MapGL = __webpack_require__(2);\n\nObject.defineProperty(exports, 'default', {\n enumerable: true,\n get: function get() {\n return _interopRequireDefault(_MapGL).default;\n }\n});\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _mapboxGl = __webpack_require__(3);\n\nvar _mapboxGl2 = _interopRequireDefault(_mapboxGl);\n\nvar _immutable = __webpack_require__(0);\n\nvar _react = __webpack_require__(4);\n\nvar _diffStyles2 = __webpack_require__(5);\n\nvar _diffStyles3 = _interopRequireDefault(_diffStyles2);\n\nvar _styleUtils = __webpack_require__(6);\n\nvar _styleUtils2 = _interopRequireDefault(_styleUtils);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nfunction noop() {}\n\n/**\n * Properties\n */\n\nvar MapGL = function (_PureComponent) {\n _inherits(MapGL, _PureComponent);\n\n _createClass(MapGL, null, [{\n key: 'supported',\n value: function supported() {\n return _mapboxGl2.default && _mapboxGl2.default.supported();\n }\n }]);\n\n function MapGL(props) {\n _classCallCheck(this, MapGL);\n\n var _this = _possibleConstructorReturn(this, (MapGL.__proto__ || Object.getPrototypeOf(MapGL)).call(this, props));\n\n _this._queryParams = {};\n\n if (_mapboxGl2.default) {\n _mapboxGl2.default.accessToken = props.accessToken;\n }\n\n if (!MapGL.supported()) {\n _this.componentDidMount = noop;\n _this.componentWillReceiveProps = noop;\n _this.componentDidUpdate = noop;\n }\n\n _this._onClick = _this._onClick.bind(_this);\n _this._onViewportChange = _this._onViewportChange.bind(_this);\n return _this;\n }\n\n _createClass(MapGL, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n if (!_mapboxGl2.default) {\n return;\n }\n\n var mapStyle = _immutable.Map.isMap(this.props.mapStyle) ? this.props.mapStyle.toJS() : this.props.mapStyle;\n\n var map = new _mapboxGl2.default.Map({\n container: this._container,\n style: mapStyle,\n center: [this.props.longitude, this.props.latitude],\n zoom: this.props.zoom,\n pitch: this.props.pitch,\n bearing: this.props.bearing,\n interactive: !!this.props.onViewportChange,\n attributionControl: this.props.attributionControl,\n preserveDrawingBuffer: this.props.preserveDrawingBuffer\n });\n\n // Disable outline style\n var canvas = map.getCanvas();\n if (canvas) {\n canvas.style.outline = 'none';\n }\n\n // Attach optional onLoad function\n if (this.props.onLoad) {\n map.once('load', this.props.onLoad);\n }\n\n map.on('click', this._onClick);\n map.on('dragend', this._onViewportChange);\n map.on('zoomend', this._onViewportChange);\n\n this._map = map;\n this._updateMapViewport(this.props);\n this._updateQueryParams(this.props.mapStyle);\n }\n }, {\n key: 'componentWillReceiveProps',\n value: function componentWillReceiveProps(newProps) {\n if (!_mapboxGl2.default) {\n return;\n }\n\n this._updateMapViewport(newProps);\n this._updateMapStyle(this.props, newProps);\n }\n }, {\n key: 'componentWillUnmount',\n value: function componentWillUnmount() {\n if (!_mapboxGl2.default) {\n return;\n }\n\n if (this._map) {\n this._map.remove();\n }\n }\n\n /**\n * Exposes Mapbox GL Map instance.\n * External apps can access map this way\n *\n * @returns {mapboxgl.Map}\n */\n\n }, {\n key: 'getMap',\n value: function getMap() {\n return this._map;\n }\n\n /** Uses Mapbox's\n * queryRenderedFeatures API to find features at point or in a bounding box.\n * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures\n * To query only some of the layers, set the `interactive` property in the\n * layer style to `true`.\n * @param {[Number, Number]|[[Number, Number], [Number, Number]]} geometry -\n * Point or an array of two points defining the bounding box\n * @param {Object} parameters - query options\n */\n\n }, {\n key: 'queryRenderedFeatures',\n value: function queryRenderedFeatures(geometry, parameters) {\n var queryParams = parameters || this._queryParams;\n if (queryParams.layers && queryParams.layers.length === 0) {\n return [];\n }\n return this._map.queryRenderedFeatures(geometry, queryParams);\n }\n\n /**\n * Hover and click only query layers whose interactive property is true\n *\n * @private\n * @param {MapStyle} mapStyle\n */\n\n }, {\n key: '_updateQueryParams',\n value: function _updateQueryParams(mapStyle) {\n var interactiveLayerIds = (0, _styleUtils2.default)(mapStyle);\n this._queryParams = { layers: interactiveLayerIds };\n }\n\n /**\n * Update a source in the map style\n *\n * @private\n * @param {SourcesDiffElement} update\n */\n\n }, {\n key: '_updateSource',\n value: function _updateSource(update) {\n var map = this._map;\n var newSource = update.source.toJS();\n if (newSource.type === 'geojson') {\n var oldSource = map.getSource(update.id);\n if (oldSource.type === 'geojson') {\n // update data if no other GeoJSONSource options were changed\n var oldOpts = oldSource.workerOptions;\n if ((newSource.maxzoom === undefined || newSource.maxzoom === oldOpts.geojsonVtOptions.maxZoom) && (newSource.buffer === undefined || newSource.buffer === oldOpts.geojsonVtOptions.buffer) && (newSource.tolerance === undefined || newSource.tolerance === oldOpts.geojsonVtOptions.tolerance) && (newSource.cluster === undefined || newSource.cluster === oldOpts.cluster) && (newSource.clusterRadius === undefined || newSource.clusterRadius === oldOpts.superclusterOptions.radius) && (newSource.clusterMaxZoom === undefined || newSource.clusterMaxZoom === oldOpts.superclusterOptions.maxZoom)) {\n oldSource.setData(newSource.data);\n return;\n }\n }\n }\n\n map.removeSource(update.id);\n map.addSource(update.id, newSource);\n }\n\n /**\n * Individually update the maps source and layers that have changed if all\n * other style props haven't changed. This prevents flicking of the map when\n * styles only change sources or layers.\n *\n * @private\n * @param {MapStyle} prevStyle\n * @param {MapStyle} nextStyle\n * @returns {void}\n */\n\n }, {\n key: '_setDiffStyle',\n value: function _setDiffStyle(prevStyle, nextStyle) {\n var _this2 = this;\n\n function styleKeysMap(style) {\n return style.map(function () {\n return true;\n }).delete('layers').delete('sources').toJS();\n }\n\n var prevKeysMap = prevStyle && (styleKeysMap(prevStyle) || {});\n var nextKeysMap = styleKeysMap(nextStyle);\n\n function propsOtherThanLayersOrSourcesDiffer() {\n var prevKeysList = Object.keys(prevKeysMap);\n var nextKeysList = Object.keys(nextKeysMap);\n if (prevKeysList.length !== nextKeysList.length) {\n return true;\n }\n // `nextStyle` and `prevStyle` should not have the same set of props.\n if (nextKeysList.some(function (key) {\n return prevStyle.get(key) !== nextStyle.get(key);\n }\n // But the value of one of those props is different.\n )) {\n return true;\n }\n return false;\n }\n\n var map = this._map;\n\n if (!prevStyle || propsOtherThanLayersOrSourcesDiffer()) {\n map.setStyle(nextStyle.toJS());\n return;\n }\n\n var _diffStyles = (0, _diffStyles3.default)(prevStyle, nextStyle),\n sourcesDiff = _diffStyles.sourcesDiff,\n layersDiff = _diffStyles.layersDiff;\n\n // TODO: It's rather difficult to determine style diffing in the presence\n // of refs. For now, if any style update has a ref, fallback to no diffing.\n // We can come back to this case if there's a solid usecase.\n\n\n if (layersDiff.updates.some(function (node) {\n return node.layer.get('ref');\n })) {\n map.setStyle(nextStyle.toJS());\n return;\n }\n\n sourcesDiff.enter.forEach(function (enter) {\n return map.addSource(enter.id, enter.source.toJS());\n });\n\n sourcesDiff.update.forEach(function (update) {\n return _this2._updateSource(update);\n });\n\n sourcesDiff.exit.forEach(function (exit) {\n return map.removeSource(exit.id);\n });\n\n layersDiff.exiting.forEach(function (exit) {\n if (map.style.getLayer(exit.id)) {\n map.removeLayer(exit.id);\n }\n });\n\n layersDiff.updates.forEach(function (update) {\n if (!update.enter) {\n // This is an old layer that needs to be updated. Remove the old layer\n // with the same id and add it back again.\n map.removeLayer(update.id);\n }\n map.addLayer(update.layer.toJS(), update.before);\n });\n }\n\n /**\n * Update Map style from newProps\n *\n * @private\n * @param {Props} oldProps\n * @param {Props} newProps\n */\n\n }, {\n key: '_updateMapStyle',\n value: function _updateMapStyle(oldProps, newProps) {\n var mapStyle = newProps.mapStyle;\n var oldMapStyle = oldProps.mapStyle;\n if (mapStyle !== oldMapStyle) {\n if (_immutable.Map.isMap(mapStyle)) {\n if (this.props.preventStyleDiffing) {\n this._map.setStyle(mapStyle.toJS());\n } else {\n this._setDiffStyle(oldMapStyle, mapStyle);\n }\n } else {\n this._map.setStyle(mapStyle);\n }\n this._updateQueryParams(mapStyle);\n }\n }\n\n /**\n * Update Map viewport from newProps\n *\n * @private\n * @param {Props} newProps\n */\n\n }, {\n key: '_updateMapViewport',\n value: function _updateMapViewport(newProps) {\n var map = this._map;\n var center = map.getCenter();\n\n var viewportChanged = newProps.latitude !== center.lat || newProps.longitude !== center.lng || newProps.zoom !== map.getZoom() || newProps.pitch !== map.getPitch() || newProps.bearing !== map.getBearing();\n\n if (viewportChanged) {\n map.flyTo({\n center: [newProps.longitude, newProps.latitude],\n zoom: newProps.zoom,\n pitch: newProps.pitch,\n bearing: newProps.bearing\n });\n }\n }\n\n /**\n * fires `onViewportChange` callback when the user interacted with the map.\n *\n * @private\n * @param {(mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent)} event\n */\n\n }, {\n key: '_onViewportChange',\n value: function _onViewportChange(event) {\n var map = event.target;\n\n var _map$getCenter = map.getCenter(),\n lng = _map$getCenter.lng,\n lat = _map$getCenter.lat;\n\n var zoom = map.getZoom();\n var pitch = map.getPitch();\n var bearing = map.getBearing();\n\n var viewport = {\n latitude: lat,\n longitude: lng,\n zoom: zoom,\n pitch: pitch,\n bearing: bearing\n };\n\n this.props.onViewportChange(viewport);\n }\n }, {\n key: '_getFeatures',\n value: function _getFeatures(position, radius) {\n // Radius enables point features, like marker symbols, to be clicked.\n if (radius) {\n var bbox = [[position[0] - radius, position[1] - radius], [position[0] + radius, position[1] + radius]];\n\n return this._map.queryRenderedFeatures(bbox, this._queryParams);\n }\n\n return this._map.queryRenderedFeatures(position, this._queryParams);\n }\n }, {\n key: '_onClick',\n value: function _onClick(event) {\n if (this.props.onClick) {\n var position = [event.point.x, event.point.y];\n\n /* eslint-disable no-param-reassign */\n event.features = this._getFeatures(position, this.props.clickRadius);\n\n this.props.onClick(event);\n }\n }\n }, {\n key: 'render',\n value: function render() {\n var _this3 = this;\n\n var _props = this.props,\n className = _props.className,\n style = _props.style;\n\n\n return (0, _react.createElement)('div', {\n ref: function ref(_ref) {\n return _this3._container = _ref;\n },\n style: style,\n className: className\n });\n }\n }]);\n\n return MapGL;\n}(_react.PureComponent);\n\nMapGL.displayName = 'MapGL';\nMapGL.defaultProps = {\n className: null,\n mapStyle: 'mapbox://styles/mapbox/light-v8',\n accessToken: null,\n preserveDrawingBuffer: false,\n onViewportChange: null,\n onClick: null,\n clickRadius: 0,\n attributionControl: true,\n preventStyleDiffing: false,\n bearing: 0,\n pitch: 0,\n onLoad: null\n};\n\nexports.default = MapGL;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_3__;\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_4__;\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.diffSources = diffSources;\nexports.diffLayers = diffLayers;\nexports.default = diffStyle;\nfunction diffSources(prevStyle, nextStyle) {\n var prevSources = prevStyle.get('sources');\n var nextSources = nextStyle.get('sources');\n var enter = [];\n var update = [];\n var exit = [];\n var prevIds = prevSources.keySeq().toArray();\n var nextIds = nextSources.keySeq().toArray();\n prevIds.forEach(function (id) {\n var nextSource = nextSources.get(id);\n if (nextSource) {\n if (!nextSource.equals(prevSources.get(id))) {\n update.push({ id: id, source: nextSources.get(id) });\n }\n } else {\n exit.push({ id: id, source: prevSources.get(id) });\n }\n });\n nextIds.forEach(function (id) {\n var prevSource = prevSources.get(id);\n if (!prevSource) {\n enter.push({ id: id, source: nextSources.get(id) });\n }\n });\n return { enter: enter, update: update, exit: exit };\n}\n\n// Copyright (c) 2015 Uber Technologies, Inc.\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nfunction diffLayers(prevStyle, nextStyle) {\n var prevLayers = prevStyle.get('layers');\n var nextLayers = nextStyle.get('layers');\n var updates = [];\n var exiting = [];\n var prevMap = {};\n var nextMap = {};\n nextLayers.forEach(function (layer, index) {\n var id = layer.get('id');\n var layerImBehind = nextLayers.get(index + 1);\n nextMap[id] = {\n layer: layer,\n id: id,\n // The `id` of the layer before this one.\n before: layerImBehind ? layerImBehind.get('id') : null,\n enter: true\n };\n });\n prevLayers.forEach(function (layer, index) {\n var id = layer.get('id');\n var layerImBehind = prevLayers.get(index + 1);\n prevMap[id] = {\n layer: layer,\n id: id,\n before: layerImBehind ? layerImBehind.get('id') : null\n };\n if (nextMap[id]) {\n // Not a new layer.\n nextMap[id].enter = false;\n } else {\n // This layer is being removed.\n exiting.push(prevMap[id]);\n }\n });\n nextLayers.reverse().forEach(function (layer) {\n var id = layer.get('id');\n if (!prevMap[id] || !prevMap[id].layer.equals(nextMap[id].layer) || prevMap[id].before !== nextMap[id].before) {\n // This layer is being changed.\n updates.push(nextMap[id]);\n }\n });\n return { updates: updates, exiting: exiting };\n}\n\nfunction diffStyle(prevStyle, nextStyle) {\n return {\n sourcesDiff: diffSources(prevStyle, nextStyle),\n layersDiff: diffLayers(prevStyle, nextStyle)\n };\n}\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _immutable = __webpack_require__(0);\n\nfunction getInteractiveLayerIds(mapStyle) {\n if (_immutable.Map.isMap(mapStyle)) {\n var layers = mapStyle.get('layers');\n if (layers) {\n return layers.filter(function (l) {\n return l.get('interactive');\n }).map(function (l) {\n return l.get('id');\n }).toJS();\n }\n }\n\n return [];\n}\n\nexports.default = getInteractiveLayerIds;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// bundle.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 7fa5850c894d9607d5f1","module.exports = __WEBPACK_EXTERNAL_MODULE_0__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"immutable\"\n// module id = 0\n// module chunks = 0","export { default } from './components/MapGL';\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js","/* @flow */\n\nimport mapboxgl from 'mapbox-gl';\nimport { Map } from 'immutable';\nimport { PureComponent, createElement } from 'react';\n\nimport diffStyles from '../utils/diff-styles';\nimport getInteractiveLayerIds from '../utils/style-utils';\n\nimport type { MapStyle, SourcesDiffElement, Viewport } from '../types';\n\nfunction noop() {}\n\n/**\n * Properties\n */\ntype Props = {\n /** container className */\n className: string,\n\n /** container style */\n style: Object,\n\n /** Mapbox API access token for mapbox-gl-js. Required when using Mapbox vector tiles/styles. */\n accessToken: string,\n\n /** Mapbox WebGL context creation option. Useful when you want to export the canvas as a PNG. */\n preserveDrawingBuffer: boolean,\n\n /** Show attribution control or not. */\n attributionControl: boolean,\n\n /** The Mapbox style. A string url or a MapboxGL style Immutable.Map object. */\n mapStyle: MapStyle,\n\n /** There are known issues with style diffing. As stopgap, add option to prevent style diffing. */\n preventStyleDiffing: boolean,\n\n /**\n * `onViewportChange` callback is fired when the user interacted with the\n * map. The object passed to the callback contains viewport properties\n * such as `longitude`, `latitude`, `zoom` etc.\n */\n onViewportChange: (viewport: Viewport) => mixed,\n\n /**\n * Called when the map is clicked.\n * @callback\n * @param {Object} event - The mouse event.\n * @param {[Number, Number]} event.lngLat - The coordinates of the pointer\n * @param {Array} event.features - The features under the pointer, using Mapbox's\n * queryRenderedFeatures API:\n * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures\n * To make a layer interactive, set the `interactive` property in the\n * layer style to `true`. See Mapbox's style spec\n * https://www.mapbox.com/mapbox-gl-style-spec/#layer-interactive\n */\n onClick: (event: mapboxgl.MapEvent) => mixed,\n\n /** Radius to detect features around a clicked point. Defaults to 0. */\n clickRadius: number,\n\n /** The longitude of the center of the map. */\n longitude: number,\n\n /** The latitude of the center of the map. */\n latitude: number,\n\n /** The tile zoom level of the map. */\n zoom: number,\n\n /** Specify the bearing of the viewport */\n bearing: number,\n\n /** Specify the pitch of the viewport */\n pitch: number,\n\n /** The onLoad callback for the map */\n onLoad: Function\n};\n\nclass MapGL extends PureComponent {\n props: Props;\n\n componentDidMount: Function;\n componentWillReceiveProps: Function;\n componentDidUpdate: Function;\n\n _map: mapboxgl.Map;\n _container: HTMLElement;\n _queryParams: Object;\n _onViewportChange: (event: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent) => void;\n\n static supported() {\n return mapboxgl && mapboxgl.supported();\n }\n\n constructor(props: Props) {\n super(props);\n this._queryParams = {};\n\n if (mapboxgl) {\n mapboxgl.accessToken = props.accessToken;\n }\n\n if (!MapGL.supported()) {\n this.componentDidMount = noop;\n this.componentWillReceiveProps = noop;\n this.componentDidUpdate = noop;\n }\n\n this._onClick = this._onClick.bind(this);\n this._onViewportChange = this._onViewportChange.bind(this);\n }\n\n componentDidMount() {\n if (!mapboxgl) {\n return;\n }\n\n const mapStyle = Map.isMap(this.props.mapStyle)\n ? this.props.mapStyle.toJS()\n : this.props.mapStyle;\n\n const map = new mapboxgl.Map({\n container: this._container,\n style: mapStyle,\n center: [this.props.longitude, this.props.latitude],\n zoom: this.props.zoom,\n pitch: this.props.pitch,\n bearing: this.props.bearing,\n interactive: !!this.props.onViewportChange,\n attributionControl: this.props.attributionControl,\n preserveDrawingBuffer: this.props.preserveDrawingBuffer\n });\n\n // Disable outline style\n const canvas = map.getCanvas();\n if (canvas) {\n canvas.style.outline = 'none';\n }\n\n // Attach optional onLoad function\n if (this.props.onLoad) {\n map.once('load', this.props.onLoad);\n }\n\n map.on('click', this._onClick);\n map.on('dragend', this._onViewportChange);\n map.on('zoomend', this._onViewportChange);\n\n this._map = map;\n this._updateMapViewport(this.props);\n this._updateQueryParams(this.props.mapStyle);\n }\n\n componentWillReceiveProps(newProps: Props) {\n if (!mapboxgl) {\n return;\n }\n\n this._updateMapViewport(newProps);\n this._updateMapStyle(this.props, newProps);\n }\n\n componentWillUnmount() {\n if (!mapboxgl) {\n return;\n }\n\n if (this._map) {\n this._map.remove();\n }\n }\n\n /**\n * Exposes Mapbox GL Map instance.\n * External apps can access map this way\n *\n * @returns {mapboxgl.Map}\n */\n getMap(): mapboxgl.Map {\n return this._map;\n }\n\n /** Uses Mapbox's\n * queryRenderedFeatures API to find features at point or in a bounding box.\n * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures\n * To query only some of the layers, set the `interactive` property in the\n * layer style to `true`.\n * @param {[Number, Number]|[[Number, Number], [Number, Number]]} geometry -\n * Point or an array of two points defining the bounding box\n * @param {Object} parameters - query options\n */\n queryRenderedFeatures(geometry: mapboxgl.Point | mapboxgl.Point[], parameters: Object) {\n const queryParams = parameters || this._queryParams;\n if (queryParams.layers && queryParams.layers.length === 0) {\n return [];\n }\n return this._map.queryRenderedFeatures(geometry, queryParams);\n }\n\n /**\n * Hover and click only query layers whose interactive property is true\n *\n * @private\n * @param {MapStyle} mapStyle\n */\n _updateQueryParams(mapStyle: MapStyle): void {\n const interactiveLayerIds = getInteractiveLayerIds(mapStyle);\n this._queryParams = { layers: interactiveLayerIds };\n }\n\n /**\n * Update a source in the map style\n *\n * @private\n * @param {SourcesDiffElement} update\n */\n _updateSource(update: SourcesDiffElement): void {\n const map = this._map;\n const newSource = update.source.toJS();\n if (newSource.type === 'geojson') {\n const oldSource = map.getSource(update.id);\n if (oldSource.type === 'geojson') {\n // update data if no other GeoJSONSource options were changed\n const oldOpts = oldSource.workerOptions;\n if (\n (newSource.maxzoom === undefined ||\n newSource.maxzoom === oldOpts.geojsonVtOptions.maxZoom) &&\n (newSource.buffer === undefined ||\n newSource.buffer === oldOpts.geojsonVtOptions.buffer) &&\n (newSource.tolerance === undefined ||\n newSource.tolerance === oldOpts.geojsonVtOptions.tolerance) &&\n (newSource.cluster === undefined ||\n newSource.cluster === oldOpts.cluster) &&\n (newSource.clusterRadius === undefined ||\n newSource.clusterRadius === oldOpts.superclusterOptions.radius) &&\n (newSource.clusterMaxZoom === undefined ||\n newSource.clusterMaxZoom === oldOpts.superclusterOptions.maxZoom)\n ) {\n oldSource.setData(newSource.data);\n return;\n }\n }\n }\n\n map.removeSource(update.id);\n map.addSource(update.id, newSource);\n }\n\n /**\n * Individually update the maps source and layers that have changed if all\n * other style props haven't changed. This prevents flicking of the map when\n * styles only change sources or layers.\n *\n * @private\n * @param {MapStyle} prevStyle\n * @param {MapStyle} nextStyle\n * @returns {void}\n */\n _setDiffStyle(prevStyle: MapStyle, nextStyle: MapStyle): void {\n function styleKeysMap(style: MapStyle) {\n return style.map(() => true).delete('layers').delete('sources').toJS();\n }\n\n const prevKeysMap = prevStyle && (styleKeysMap(prevStyle) || {});\n const nextKeysMap = styleKeysMap(nextStyle);\n\n function propsOtherThanLayersOrSourcesDiffer() {\n const prevKeysList = Object.keys(prevKeysMap);\n const nextKeysList = Object.keys(nextKeysMap);\n if (prevKeysList.length !== nextKeysList.length) {\n return true;\n }\n // `nextStyle` and `prevStyle` should not have the same set of props.\n if (\n nextKeysList.some(\n key => prevStyle.get(key) !== nextStyle.get(key)\n // But the value of one of those props is different.\n )\n ) {\n return true;\n }\n return false;\n }\n\n const map = this._map;\n\n if (!prevStyle || propsOtherThanLayersOrSourcesDiffer()) {\n map.setStyle(nextStyle.toJS());\n return;\n }\n\n const { sourcesDiff, layersDiff } = diffStyles(prevStyle, nextStyle);\n\n // TODO: It's rather difficult to determine style diffing in the presence\n // of refs. For now, if any style update has a ref, fallback to no diffing.\n // We can come back to this case if there's a solid usecase.\n if (layersDiff.updates.some(node => node.layer.get('ref'))) {\n map.setStyle(nextStyle.toJS());\n return;\n }\n\n sourcesDiff.enter.forEach(enter =>\n map.addSource(enter.id, enter.source.toJS())\n );\n\n sourcesDiff.update.forEach(update => this._updateSource(update));\n\n sourcesDiff.exit.forEach(exit => map.removeSource(exit.id));\n\n layersDiff.exiting.forEach((exit) => {\n if (map.style.getLayer(exit.id)) {\n map.removeLayer(exit.id);\n }\n });\n\n layersDiff.updates.forEach((update) => {\n if (!update.enter) {\n // This is an old layer that needs to be updated. Remove the old layer\n // with the same id and add it back again.\n map.removeLayer(update.id);\n }\n map.addLayer(update.layer.toJS(), update.before);\n });\n }\n\n /**\n * Update Map style from newProps\n *\n * @private\n * @param {Props} oldProps\n * @param {Props} newProps\n */\n _updateMapStyle(oldProps: Props, newProps: Props): void {\n const mapStyle = newProps.mapStyle;\n const oldMapStyle = oldProps.mapStyle;\n if (mapStyle !== oldMapStyle) {\n if (Map.isMap(mapStyle)) {\n if (this.props.preventStyleDiffing) {\n this._map.setStyle(mapStyle.toJS());\n } else {\n this._setDiffStyle(oldMapStyle, mapStyle);\n }\n } else {\n this._map.setStyle(mapStyle);\n }\n this._updateQueryParams(mapStyle);\n }\n }\n\n /**\n * Update Map viewport from newProps\n *\n * @private\n * @param {Props} newProps\n */\n _updateMapViewport(newProps: Props): void {\n const map = this._map;\n const center = map.getCenter();\n\n const viewportChanged =\n newProps.latitude !== center.lat ||\n newProps.longitude !== center.lng ||\n newProps.zoom !== map.getZoom() ||\n newProps.pitch !== map.getPitch() ||\n newProps.bearing !== map.getBearing();\n\n if (viewportChanged) {\n map.flyTo({\n center: [newProps.longitude, newProps.latitude],\n zoom: newProps.zoom,\n pitch: newProps.pitch,\n bearing: newProps.bearing\n });\n }\n }\n\n /**\n * fires `onViewportChange` callback when the user interacted with the map.\n *\n * @private\n * @param {(mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent)} event\n */\n _onViewportChange(event: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent): void {\n const map = event.target;\n const { lng, lat } = map.getCenter();\n const zoom = map.getZoom();\n const pitch = map.getPitch();\n const bearing = map.getBearing();\n\n const viewport = {\n latitude: lat,\n longitude: lng,\n zoom,\n pitch,\n bearing\n };\n\n this.props.onViewportChange(viewport);\n }\n\n _getFeatures(position: [number, number], radius: number) {\n // Radius enables point features, like marker symbols, to be clicked.\n if (radius) {\n const bbox = [\n [position[0] - radius, position[1] - radius],\n [position[0] + radius, position[1] + radius]\n ];\n\n return this._map.queryRenderedFeatures(bbox, this._queryParams);\n }\n\n return this._map.queryRenderedFeatures(position, this._queryParams);\n }\n\n _onClick(event: mapboxgl.MapEvent): void {\n if (this.props.onClick) {\n const position = [event.point.x, event.point.y];\n\n /* eslint-disable no-param-reassign */\n event.features = this._getFeatures(position, this.props.clickRadius);\n\n this.props.onClick(event);\n }\n }\n\n render() {\n const { className, style } = this.props;\n\n return createElement('div', {\n ref: ref => this._container = ref,\n style,\n className\n });\n }\n}\n\nMapGL.displayName = 'MapGL';\nMapGL.defaultProps = {\n className: null,\n mapStyle: 'mapbox://styles/mapbox/light-v8',\n accessToken: null,\n preserveDrawingBuffer: false,\n onViewportChange: null,\n onClick: null,\n clickRadius: 0,\n attributionControl: true,\n preventStyleDiffing: false,\n bearing: 0,\n pitch: 0,\n onLoad: null\n};\n\nexport default MapGL;\n\n\n\n// WEBPACK FOOTER //\n// ./src/components/MapGL.js","module.exports = __WEBPACK_EXTERNAL_MODULE_3__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"mapbox-gl\"\n// module id = 3\n// module chunks = 0","module.exports = __WEBPACK_EXTERNAL_MODULE_4__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"react\"\n// module id = 4\n// module chunks = 0","/* @flow */\n\n// Copyright (c) 2015 Uber Technologies, Inc.\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport type { MapStyle, SourcesDiff, LayersDiff } from '../types';\n\nexport function diffSources(prevStyle: MapStyle, nextStyle: MapStyle): SourcesDiff {\n const prevSources = prevStyle.get('sources');\n const nextSources = nextStyle.get('sources');\n const enter = [];\n const update = [];\n const exit = [];\n const prevIds = prevSources.keySeq().toArray();\n const nextIds = nextSources.keySeq().toArray();\n prevIds.forEach((id) => {\n const nextSource = nextSources.get(id);\n if (nextSource) {\n if (!nextSource.equals(prevSources.get(id))) {\n update.push({ id, source: nextSources.get(id) });\n }\n } else {\n exit.push({ id, source: prevSources.get(id) });\n }\n });\n nextIds.forEach((id) => {\n const prevSource = prevSources.get(id);\n if (!prevSource) {\n enter.push({ id, source: nextSources.get(id) });\n }\n });\n return { enter, update, exit };\n}\n\nexport function diffLayers(prevStyle: MapStyle, nextStyle: MapStyle): LayersDiff {\n const prevLayers = prevStyle.get('layers');\n const nextLayers = nextStyle.get('layers');\n const updates = [];\n const exiting = [];\n const prevMap = {};\n const nextMap = {};\n nextLayers.forEach((layer, index) => {\n const id = layer.get('id');\n const layerImBehind = nextLayers.get(index + 1);\n nextMap[id] = {\n layer,\n id,\n // The `id` of the layer before this one.\n before: layerImBehind ? layerImBehind.get('id') : null,\n enter: true\n };\n });\n prevLayers.forEach((layer, index) => {\n const id = layer.get('id');\n const layerImBehind = prevLayers.get(index + 1);\n prevMap[id] = {\n layer,\n id,\n before: layerImBehind ? layerImBehind.get('id') : null\n };\n if (nextMap[id]) {\n // Not a new layer.\n nextMap[id].enter = false;\n } else {\n // This layer is being removed.\n exiting.push(prevMap[id]);\n }\n });\n nextLayers.reverse().forEach((layer) => {\n const id = layer.get('id');\n if (\n !prevMap[id] ||\n !prevMap[id].layer.equals(nextMap[id].layer) ||\n prevMap[id].before !== nextMap[id].before\n ) {\n // This layer is being changed.\n updates.push(nextMap[id]);\n }\n });\n return { updates, exiting };\n}\n\nexport default function diffStyle(prevStyle: MapStyle, nextStyle: MapStyle) {\n return {\n sourcesDiff: diffSources(prevStyle, nextStyle),\n layersDiff: diffLayers(prevStyle, nextStyle)\n };\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/diff-styles.js","/* @flow */\n\nimport { Map } from 'immutable';\nimport type { MapStyle } from '../types';\n\nfunction getInteractiveLayerIds(mapStyle: MapStyle): Array {\n if (Map.isMap(mapStyle)) {\n const layers = mapStyle.get('layers');\n if (layers) {\n return layers\n .filter(l => l.get('interactive'))\n .map(l => l.get('id'))\n .toJS();\n }\n }\n\n return [];\n}\n\nexport default getInteractiveLayerIds;\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/style-utils.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///bundle.js","webpack:///webpack/bootstrap e28b68f0bf4b20931915","webpack:///external \"immutable\"","webpack:///./src/index.js","webpack:///./src/components/MapGL.js","webpack:///external \"mapbox-gl\"","webpack:///external \"react\"","webpack:///./src/utils/diff-styles.js","webpack:///./src/utils/style-utils.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_0__","__WEBPACK_EXTERNAL_MODULE_3__","__WEBPACK_EXTERNAL_MODULE_4__","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_interopRequireDefault","obj","default","value","_MapGL","_classCallCheck","instance","Constructor","TypeError","_possibleConstructorReturn","self","ReferenceError","_inherits","subClass","superClass","create","constructor","writable","setPrototypeOf","__proto__","noop","_createClass","defineProperties","target","props","length","descriptor","key","protoProps","staticProps","_mapboxGl","_mapboxGl2","_immutable","_react","_diffStyles2","_diffStyles3","_styleUtils","_styleUtils2","MapGL","_PureComponent","_this","getPrototypeOf","_queryParams","accessToken","supported","componentDidMount","componentWillReceiveProps","componentDidUpdate","_onClick","bind","_onHover","_onViewportChange","mapStyle","Map","isMap","toJS","map","container","_container","style","center","longitude","latitude","zoom","pitch","bearing","interactive","onViewportChange","attributionControl","preserveDrawingBuffer","canvas","getCanvas","outline","onLoad","once","on","_map","_updateMapViewport","_updateQueryParams","newProps","_updateMapStyle","remove","geometry","parameters","queryParams","layers","queryRenderedFeatures","interactiveLayerIds","update","newSource","source","type","oldSource","getSource","id","oldOpts","workerOptions","undefined","maxzoom","geojsonVtOptions","maxZoom","buffer","tolerance","cluster","clusterRadius","superclusterOptions","radius","clusterMaxZoom","setData","data","removeSource","addSource","prevStyle","nextStyle","styleKeysMap","delete","_this2","prevKeysMap","nextKeysMap","prevKeysList","keys","nextKeysList","some","setStyle","_diffStyles","sourcesDiff","layersDiff","updates","node","layer","enter","forEach","_updateSource","exit","exiting","getLayer","removeLayer","addLayer","before","oldProps","oldMapStyle","preventStyleDiffing","_setDiffStyle","getCenter","lat","lng","getZoom","getPitch","getBearing","flyTo","event","_map$getCenter","viewport","position","bbox","onHover","point","x","y","features","_getFeatures","clickRadius","onClick","_this3","_props","className","createElement","ref","_ref","PureComponent","displayName","defaultProps","diffSources","prevSources","nextSources","prevIds","keySeq","toArray","nextIds","nextSource","equals","push","diffLayers","prevLayers","nextLayers","prevMap","nextMap","index","layerImBehind","reverse","diffStyle","getInteractiveLayerIds","filter"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,aAAAA,QAAA,aAAAA,QAAA,UACA,kBAA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QqC,QQlsBO6L","file":"bundle.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"immutable\"), require(\"mapbox-gl\"), require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"immutable\", \"mapbox-gl\", \"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@urbica/react-map-gl\"] = factory(require(\"immutable\"), require(\"mapbox-gl\"), require(\"react\"));\n\telse\n\t\troot[\"@urbica/react-map-gl\"] = factory(root[\"immutable\"], root[\"mapbox-gl\"], root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_4__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"immutable\"), require(\"mapbox-gl\"), require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"immutable\", \"mapbox-gl\", \"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@urbica/react-map-gl\"] = factory(require(\"immutable\"), require(\"mapbox-gl\"), require(\"react\"));\n\telse\n\t\troot[\"@urbica/react-map-gl\"] = factory(root[\"immutable\"], root[\"mapbox-gl\"], root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_4__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 1);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_0__;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _MapGL = __webpack_require__(2);\n\nObject.defineProperty(exports, 'default', {\n enumerable: true,\n get: function get() {\n return _interopRequireDefault(_MapGL).default;\n }\n});\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _mapboxGl = __webpack_require__(3);\n\nvar _mapboxGl2 = _interopRequireDefault(_mapboxGl);\n\nvar _immutable = __webpack_require__(0);\n\nvar _react = __webpack_require__(4);\n\nvar _diffStyles2 = __webpack_require__(5);\n\nvar _diffStyles3 = _interopRequireDefault(_diffStyles2);\n\nvar _styleUtils = __webpack_require__(6);\n\nvar _styleUtils2 = _interopRequireDefault(_styleUtils);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nfunction noop() {}\n\n/**\n * Properties\n */\n\nvar MapGL = function (_PureComponent) {\n _inherits(MapGL, _PureComponent);\n\n _createClass(MapGL, null, [{\n key: 'supported',\n value: function supported() {\n return _mapboxGl2.default && _mapboxGl2.default.supported();\n }\n }]);\n\n function MapGL(props) {\n _classCallCheck(this, MapGL);\n\n var _this = _possibleConstructorReturn(this, (MapGL.__proto__ || Object.getPrototypeOf(MapGL)).call(this, props));\n\n _this._queryParams = {};\n\n if (_mapboxGl2.default) {\n _mapboxGl2.default.accessToken = props.accessToken;\n }\n\n if (!MapGL.supported()) {\n _this.componentDidMount = noop;\n _this.componentWillReceiveProps = noop;\n _this.componentDidUpdate = noop;\n }\n\n _this._onClick = _this._onClick.bind(_this);\n _this._onHover = _this._onHover.bind(_this);\n _this._onViewportChange = _this._onViewportChange.bind(_this);\n return _this;\n }\n\n _createClass(MapGL, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n if (!_mapboxGl2.default) {\n return;\n }\n\n var mapStyle = _immutable.Map.isMap(this.props.mapStyle) ? this.props.mapStyle.toJS() : this.props.mapStyle;\n\n var map = new _mapboxGl2.default.Map({\n container: this._container,\n style: mapStyle,\n center: [this.props.longitude, this.props.latitude],\n zoom: this.props.zoom,\n pitch: this.props.pitch,\n bearing: this.props.bearing,\n interactive: !!this.props.onViewportChange,\n attributionControl: this.props.attributionControl,\n preserveDrawingBuffer: this.props.preserveDrawingBuffer\n });\n\n // Disable outline style\n var canvas = map.getCanvas();\n if (canvas) {\n canvas.style.outline = 'none';\n }\n\n // Attach optional onLoad function\n if (this.props.onLoad) {\n map.once('load', this.props.onLoad);\n }\n\n map.on('click', this._onClick);\n map.on('mousemove', this._onHover);\n map.on('dragend', this._onViewportChange);\n map.on('zoomend', this._onViewportChange);\n\n this._map = map;\n this._updateMapViewport(this.props);\n this._updateQueryParams(this.props.mapStyle);\n }\n }, {\n key: 'componentWillReceiveProps',\n value: function componentWillReceiveProps(newProps) {\n if (!_mapboxGl2.default) {\n return;\n }\n\n this._updateMapViewport(newProps);\n this._updateMapStyle(this.props, newProps);\n }\n }, {\n key: 'componentWillUnmount',\n value: function componentWillUnmount() {\n if (!_mapboxGl2.default) {\n return;\n }\n\n if (this._map) {\n this._map.remove();\n }\n }\n\n /**\n * Exposes Mapbox GL Map instance.\n * External apps can access map this way\n *\n * @returns {mapboxgl.Map}\n */\n\n }, {\n key: 'getMap',\n value: function getMap() {\n return this._map;\n }\n\n /** Uses Mapbox's\n * queryRenderedFeatures API to find features at point or in a bounding box.\n * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures\n * To query only some of the layers, set the `interactive` property in the\n * layer style to `true`.\n * @param {[Number, Number]|[[Number, Number], [Number, Number]]} geometry -\n * Point or an array of two points defining the bounding box\n * @param {Object} parameters - query options\n */\n\n }, {\n key: 'queryRenderedFeatures',\n value: function queryRenderedFeatures(geometry, parameters) {\n var queryParams = parameters || this._queryParams;\n if (queryParams.layers && queryParams.layers.length === 0) {\n return [];\n }\n return this._map.queryRenderedFeatures(geometry, queryParams);\n }\n\n /**\n * Hover and click only query layers whose interactive property is true\n *\n * @private\n * @param {MapStyle} mapStyle\n */\n\n }, {\n key: '_updateQueryParams',\n value: function _updateQueryParams(mapStyle) {\n var interactiveLayerIds = (0, _styleUtils2.default)(mapStyle);\n this._queryParams = { layers: interactiveLayerIds };\n }\n\n /**\n * Update a source in the map style\n *\n * @private\n * @param {SourcesDiffElement} update\n */\n\n }, {\n key: '_updateSource',\n value: function _updateSource(update) {\n var map = this._map;\n var newSource = update.source.toJS();\n if (newSource.type === 'geojson') {\n var oldSource = map.getSource(update.id);\n if (oldSource.type === 'geojson') {\n // update data if no other GeoJSONSource options were changed\n var oldOpts = oldSource.workerOptions;\n if ((newSource.maxzoom === undefined || newSource.maxzoom === oldOpts.geojsonVtOptions.maxZoom) && (newSource.buffer === undefined || newSource.buffer === oldOpts.geojsonVtOptions.buffer) && (newSource.tolerance === undefined || newSource.tolerance === oldOpts.geojsonVtOptions.tolerance) && (newSource.cluster === undefined || newSource.cluster === oldOpts.cluster) && (newSource.clusterRadius === undefined || newSource.clusterRadius === oldOpts.superclusterOptions.radius) && (newSource.clusterMaxZoom === undefined || newSource.clusterMaxZoom === oldOpts.superclusterOptions.maxZoom)) {\n oldSource.setData(newSource.data);\n return;\n }\n }\n }\n\n map.removeSource(update.id);\n map.addSource(update.id, newSource);\n }\n\n /**\n * Individually update the maps source and layers that have changed if all\n * other style props haven't changed. This prevents flicking of the map when\n * styles only change sources or layers.\n *\n * @private\n * @param {MapStyle} prevStyle\n * @param {MapStyle} nextStyle\n * @returns {void}\n */\n\n }, {\n key: '_setDiffStyle',\n value: function _setDiffStyle(prevStyle, nextStyle) {\n var _this2 = this;\n\n function styleKeysMap(style) {\n return style.map(function () {\n return true;\n }).delete('layers').delete('sources').toJS();\n }\n\n var prevKeysMap = prevStyle && (styleKeysMap(prevStyle) || {});\n var nextKeysMap = styleKeysMap(nextStyle);\n\n function propsOtherThanLayersOrSourcesDiffer() {\n var prevKeysList = Object.keys(prevKeysMap);\n var nextKeysList = Object.keys(nextKeysMap);\n if (prevKeysList.length !== nextKeysList.length) {\n return true;\n }\n // `nextStyle` and `prevStyle` should not have the same set of props.\n if (nextKeysList.some(function (key) {\n return prevStyle.get(key) !== nextStyle.get(key);\n }\n // But the value of one of those props is different.\n )) {\n return true;\n }\n return false;\n }\n\n var map = this._map;\n\n if (!prevStyle || propsOtherThanLayersOrSourcesDiffer()) {\n map.setStyle(nextStyle.toJS());\n return;\n }\n\n var _diffStyles = (0, _diffStyles3.default)(prevStyle, nextStyle),\n sourcesDiff = _diffStyles.sourcesDiff,\n layersDiff = _diffStyles.layersDiff;\n\n // TODO: It's rather difficult to determine style diffing in the presence\n // of refs. For now, if any style update has a ref, fallback to no diffing.\n // We can come back to this case if there's a solid usecase.\n\n\n if (layersDiff.updates.some(function (node) {\n return node.layer.get('ref');\n })) {\n map.setStyle(nextStyle.toJS());\n return;\n }\n\n sourcesDiff.enter.forEach(function (enter) {\n return map.addSource(enter.id, enter.source.toJS());\n });\n\n sourcesDiff.update.forEach(function (update) {\n return _this2._updateSource(update);\n });\n\n sourcesDiff.exit.forEach(function (exit) {\n return map.removeSource(exit.id);\n });\n\n layersDiff.exiting.forEach(function (exit) {\n if (map.style.getLayer(exit.id)) {\n map.removeLayer(exit.id);\n }\n });\n\n layersDiff.updates.forEach(function (update) {\n if (!update.enter) {\n // This is an old layer that needs to be updated. Remove the old layer\n // with the same id and add it back again.\n map.removeLayer(update.id);\n }\n map.addLayer(update.layer.toJS(), update.before);\n });\n }\n\n /**\n * Update Map style from newProps\n *\n * @private\n * @param {Props} oldProps\n * @param {Props} newProps\n */\n\n }, {\n key: '_updateMapStyle',\n value: function _updateMapStyle(oldProps, newProps) {\n var mapStyle = newProps.mapStyle;\n var oldMapStyle = oldProps.mapStyle;\n if (mapStyle !== oldMapStyle) {\n if (_immutable.Map.isMap(mapStyle)) {\n if (this.props.preventStyleDiffing) {\n this._map.setStyle(mapStyle.toJS());\n } else {\n this._setDiffStyle(oldMapStyle, mapStyle);\n }\n } else {\n this._map.setStyle(mapStyle);\n }\n this._updateQueryParams(mapStyle);\n }\n }\n\n /**\n * Update Map viewport from newProps\n *\n * @private\n * @param {Props} newProps\n */\n\n }, {\n key: '_updateMapViewport',\n value: function _updateMapViewport(newProps) {\n var map = this._map;\n var center = map.getCenter();\n\n var viewportChanged = newProps.latitude !== center.lat || newProps.longitude !== center.lng || newProps.zoom !== map.getZoom() || newProps.pitch !== map.getPitch() || newProps.bearing !== map.getBearing();\n\n if (viewportChanged) {\n map.flyTo({\n center: [newProps.longitude, newProps.latitude],\n zoom: newProps.zoom,\n pitch: newProps.pitch,\n bearing: newProps.bearing\n });\n }\n }\n\n /**\n * fires `onViewportChange` callback when the user interacted with the map.\n *\n * @private\n * @param {(mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent)} event\n */\n\n }, {\n key: '_onViewportChange',\n value: function _onViewportChange(event) {\n var map = event.target;\n\n var _map$getCenter = map.getCenter(),\n lng = _map$getCenter.lng,\n lat = _map$getCenter.lat;\n\n var zoom = map.getZoom();\n var pitch = map.getPitch();\n var bearing = map.getBearing();\n\n var viewport = {\n latitude: lat,\n longitude: lng,\n zoom: zoom,\n pitch: pitch,\n bearing: bearing\n };\n\n this.props.onViewportChange(viewport);\n }\n }, {\n key: '_getFeatures',\n value: function _getFeatures(position, radius) {\n // Radius enables point features, like marker symbols, to be clicked.\n if (radius) {\n var bbox = [[position[0] - radius, position[1] - radius], [position[0] + radius, position[1] + radius]];\n\n return this._map.queryRenderedFeatures(bbox, this._queryParams);\n }\n\n return this._map.queryRenderedFeatures(position, this._queryParams);\n }\n }, {\n key: '_onHover',\n value: function _onHover(event) {\n if (this.props.onHover) {\n var position = [event.point.x, event.point.y];\n\n /* eslint-disable no-param-reassign */\n event.features = this._getFeatures(position, this.props.clickRadius);\n /* eslint-enable no-param-reassign */\n\n if (event.features.length > 0) {\n this.props.onHover(event);\n }\n }\n }\n }, {\n key: '_onClick',\n value: function _onClick(event) {\n if (this.props.onClick) {\n var position = [event.point.x, event.point.y];\n\n /* eslint-disable no-param-reassign */\n event.features = this._getFeatures(position, this.props.clickRadius);\n /* eslint-enable no-param-reassign */\n\n this.props.onClick(event);\n }\n }\n }, {\n key: 'render',\n value: function render() {\n var _this3 = this;\n\n var _props = this.props,\n className = _props.className,\n style = _props.style;\n\n\n return (0, _react.createElement)('div', {\n ref: function ref(_ref) {\n return _this3._container = _ref;\n },\n style: style,\n className: className\n });\n }\n }]);\n\n return MapGL;\n}(_react.PureComponent);\n\nMapGL.displayName = 'MapGL';\nMapGL.defaultProps = {\n className: null,\n mapStyle: 'mapbox://styles/mapbox/light-v8',\n accessToken: null,\n preserveDrawingBuffer: false,\n onViewportChange: null,\n onClick: null,\n onHover: null,\n clickRadius: 0,\n attributionControl: true,\n preventStyleDiffing: false,\n bearing: 0,\n pitch: 0,\n onLoad: null\n};\n\nexports.default = MapGL;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_3__;\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_4__;\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.diffSources = diffSources;\nexports.diffLayers = diffLayers;\nexports.default = diffStyle;\nfunction diffSources(prevStyle, nextStyle) {\n var prevSources = prevStyle.get('sources');\n var nextSources = nextStyle.get('sources');\n var enter = [];\n var update = [];\n var exit = [];\n var prevIds = prevSources.keySeq().toArray();\n var nextIds = nextSources.keySeq().toArray();\n prevIds.forEach(function (id) {\n var nextSource = nextSources.get(id);\n if (nextSource) {\n if (!nextSource.equals(prevSources.get(id))) {\n update.push({ id: id, source: nextSources.get(id) });\n }\n } else {\n exit.push({ id: id, source: prevSources.get(id) });\n }\n });\n nextIds.forEach(function (id) {\n var prevSource = prevSources.get(id);\n if (!prevSource) {\n enter.push({ id: id, source: nextSources.get(id) });\n }\n });\n return { enter: enter, update: update, exit: exit };\n}\n\n// Copyright (c) 2015 Uber Technologies, Inc.\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nfunction diffLayers(prevStyle, nextStyle) {\n var prevLayers = prevStyle.get('layers');\n var nextLayers = nextStyle.get('layers');\n var updates = [];\n var exiting = [];\n var prevMap = {};\n var nextMap = {};\n nextLayers.forEach(function (layer, index) {\n var id = layer.get('id');\n var layerImBehind = nextLayers.get(index + 1);\n nextMap[id] = {\n layer: layer,\n id: id,\n // The `id` of the layer before this one.\n before: layerImBehind ? layerImBehind.get('id') : null,\n enter: true\n };\n });\n prevLayers.forEach(function (layer, index) {\n var id = layer.get('id');\n var layerImBehind = prevLayers.get(index + 1);\n prevMap[id] = {\n layer: layer,\n id: id,\n before: layerImBehind ? layerImBehind.get('id') : null\n };\n if (nextMap[id]) {\n // Not a new layer.\n nextMap[id].enter = false;\n } else {\n // This layer is being removed.\n exiting.push(prevMap[id]);\n }\n });\n nextLayers.reverse().forEach(function (layer) {\n var id = layer.get('id');\n if (!prevMap[id] || !prevMap[id].layer.equals(nextMap[id].layer) || prevMap[id].before !== nextMap[id].before) {\n // This layer is being changed.\n updates.push(nextMap[id]);\n }\n });\n return { updates: updates, exiting: exiting };\n}\n\nfunction diffStyle(prevStyle, nextStyle) {\n return {\n sourcesDiff: diffSources(prevStyle, nextStyle),\n layersDiff: diffLayers(prevStyle, nextStyle)\n };\n}\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _immutable = __webpack_require__(0);\n\nfunction getInteractiveLayerIds(mapStyle) {\n if (_immutable.Map.isMap(mapStyle)) {\n var layers = mapStyle.get('layers');\n if (layers) {\n return layers.filter(function (l) {\n return l.get('interactive');\n }).map(function (l) {\n return l.get('id');\n }).toJS();\n }\n }\n\n return [];\n}\n\nexports.default = getInteractiveLayerIds;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// bundle.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap e28b68f0bf4b20931915","module.exports = __WEBPACK_EXTERNAL_MODULE_0__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"immutable\"\n// module id = 0\n// module chunks = 0","export { default } from './components/MapGL';\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js","/* @flow */\n\nimport mapboxgl from 'mapbox-gl';\nimport { Map } from 'immutable';\nimport { PureComponent, createElement } from 'react';\n\nimport diffStyles from '../utils/diff-styles';\nimport getInteractiveLayerIds from '../utils/style-utils';\n\nimport type { MapStyle, SourcesDiffElement, Viewport } from '../types';\n\nfunction noop() {}\n\n/**\n * Properties\n */\ntype Props = {\n /** container className */\n className: string,\n\n /** container style */\n style: Object,\n\n /** Mapbox API access token for mapbox-gl-js. Required when using Mapbox vector tiles/styles. */\n accessToken: string,\n\n /** Mapbox WebGL context creation option. Useful when you want to export the canvas as a PNG. */\n preserveDrawingBuffer: boolean,\n\n /** Show attribution control or not. */\n attributionControl: boolean,\n\n /** The Mapbox style. A string url or a MapboxGL style Immutable.Map object. */\n mapStyle: MapStyle,\n\n /** There are known issues with style diffing. As stopgap, add option to prevent style diffing. */\n preventStyleDiffing: boolean,\n\n /**\n * `onViewportChange` callback is fired when the user interacted with the\n * map. The object passed to the callback contains viewport properties\n * such as `longitude`, `latitude`, `zoom` etc.\n */\n onViewportChange: (viewport: Viewport) => mixed,\n\n /**\n * Called when the map is hovered over.\n * @callback\n * @param {Object} event - The mouse event.\n * @param {[Number, Number]} event.lngLat - The coordinates of the pointer\n * @param {Array} event.features - The features under the pointer, using Mapbox's\n * queryRenderedFeatures API:\n * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures\n * To make a layer interactive, set the `interactive` property in the\n * layer style to `true`. See Mapbox's style spec\n * https://www.mapbox.com/mapbox-gl-style-spec/#layer-interactive\n */\n onHover: (event: mapboxgl.MapEvent) => mixed,\n\n /**\n * Called when the map is clicked.\n * @callback\n * @param {Object} event - The mouse event.\n * @param {[Number, Number]} event.lngLat - The coordinates of the pointer\n * @param {Array} event.features - The features under the pointer, using Mapbox's\n * queryRenderedFeatures API:\n * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures\n * To make a layer interactive, set the `interactive` property in the\n * layer style to `true`. See Mapbox's style spec\n * https://www.mapbox.com/mapbox-gl-style-spec/#layer-interactive\n */\n onClick: (event: mapboxgl.MapEvent) => mixed,\n\n /** Radius to detect features around a clicked point. Defaults to 0. */\n clickRadius: number,\n\n /** The longitude of the center of the map. */\n longitude: number,\n\n /** The latitude of the center of the map. */\n latitude: number,\n\n /** The tile zoom level of the map. */\n zoom: number,\n\n /** Specify the bearing of the viewport */\n bearing: number,\n\n /** Specify the pitch of the viewport */\n pitch: number,\n\n /** The onLoad callback for the map */\n onLoad: Function\n};\n\nclass MapGL extends PureComponent {\n props: Props;\n\n componentDidMount: Function;\n componentWillReceiveProps: Function;\n componentDidUpdate: Function;\n\n _map: mapboxgl.Map;\n _container: HTMLElement;\n _queryParams: Object;\n _onViewportChange: (event: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent) => void;\n\n static supported() {\n return mapboxgl && mapboxgl.supported();\n }\n\n constructor(props: Props) {\n super(props);\n this._queryParams = {};\n\n if (mapboxgl) {\n mapboxgl.accessToken = props.accessToken;\n }\n\n if (!MapGL.supported()) {\n this.componentDidMount = noop;\n this.componentWillReceiveProps = noop;\n this.componentDidUpdate = noop;\n }\n\n this._onClick = this._onClick.bind(this);\n this._onHover = this._onHover.bind(this);\n this._onViewportChange = this._onViewportChange.bind(this);\n }\n\n componentDidMount() {\n if (!mapboxgl) {\n return;\n }\n\n const mapStyle = Map.isMap(this.props.mapStyle)\n ? this.props.mapStyle.toJS()\n : this.props.mapStyle;\n\n const map = new mapboxgl.Map({\n container: this._container,\n style: mapStyle,\n center: [this.props.longitude, this.props.latitude],\n zoom: this.props.zoom,\n pitch: this.props.pitch,\n bearing: this.props.bearing,\n interactive: !!this.props.onViewportChange,\n attributionControl: this.props.attributionControl,\n preserveDrawingBuffer: this.props.preserveDrawingBuffer\n });\n\n // Disable outline style\n const canvas = map.getCanvas();\n if (canvas) {\n canvas.style.outline = 'none';\n }\n\n // Attach optional onLoad function\n if (this.props.onLoad) {\n map.once('load', this.props.onLoad);\n }\n\n map.on('click', this._onClick);\n map.on('mousemove', this._onHover);\n map.on('dragend', this._onViewportChange);\n map.on('zoomend', this._onViewportChange);\n\n this._map = map;\n this._updateMapViewport(this.props);\n this._updateQueryParams(this.props.mapStyle);\n }\n\n componentWillReceiveProps(newProps: Props) {\n if (!mapboxgl) {\n return;\n }\n\n this._updateMapViewport(newProps);\n this._updateMapStyle(this.props, newProps);\n }\n\n componentWillUnmount() {\n if (!mapboxgl) {\n return;\n }\n\n if (this._map) {\n this._map.remove();\n }\n }\n\n /**\n * Exposes Mapbox GL Map instance.\n * External apps can access map this way\n *\n * @returns {mapboxgl.Map}\n */\n getMap(): mapboxgl.Map {\n return this._map;\n }\n\n /** Uses Mapbox's\n * queryRenderedFeatures API to find features at point or in a bounding box.\n * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures\n * To query only some of the layers, set the `interactive` property in the\n * layer style to `true`.\n * @param {[Number, Number]|[[Number, Number], [Number, Number]]} geometry -\n * Point or an array of two points defining the bounding box\n * @param {Object} parameters - query options\n */\n queryRenderedFeatures(geometry: mapboxgl.Point | mapboxgl.Point[], parameters: Object) {\n const queryParams = parameters || this._queryParams;\n if (queryParams.layers && queryParams.layers.length === 0) {\n return [];\n }\n return this._map.queryRenderedFeatures(geometry, queryParams);\n }\n\n /**\n * Hover and click only query layers whose interactive property is true\n *\n * @private\n * @param {MapStyle} mapStyle\n */\n _updateQueryParams(mapStyle: MapStyle): void {\n const interactiveLayerIds = getInteractiveLayerIds(mapStyle);\n this._queryParams = { layers: interactiveLayerIds };\n }\n\n /**\n * Update a source in the map style\n *\n * @private\n * @param {SourcesDiffElement} update\n */\n _updateSource(update: SourcesDiffElement): void {\n const map = this._map;\n const newSource = update.source.toJS();\n if (newSource.type === 'geojson') {\n const oldSource = map.getSource(update.id);\n if (oldSource.type === 'geojson') {\n // update data if no other GeoJSONSource options were changed\n const oldOpts = oldSource.workerOptions;\n if (\n (newSource.maxzoom === undefined ||\n newSource.maxzoom === oldOpts.geojsonVtOptions.maxZoom) &&\n (newSource.buffer === undefined ||\n newSource.buffer === oldOpts.geojsonVtOptions.buffer) &&\n (newSource.tolerance === undefined ||\n newSource.tolerance === oldOpts.geojsonVtOptions.tolerance) &&\n (newSource.cluster === undefined ||\n newSource.cluster === oldOpts.cluster) &&\n (newSource.clusterRadius === undefined ||\n newSource.clusterRadius === oldOpts.superclusterOptions.radius) &&\n (newSource.clusterMaxZoom === undefined ||\n newSource.clusterMaxZoom === oldOpts.superclusterOptions.maxZoom)\n ) {\n oldSource.setData(newSource.data);\n return;\n }\n }\n }\n\n map.removeSource(update.id);\n map.addSource(update.id, newSource);\n }\n\n /**\n * Individually update the maps source and layers that have changed if all\n * other style props haven't changed. This prevents flicking of the map when\n * styles only change sources or layers.\n *\n * @private\n * @param {MapStyle} prevStyle\n * @param {MapStyle} nextStyle\n * @returns {void}\n */\n _setDiffStyle(prevStyle: MapStyle, nextStyle: MapStyle): void {\n function styleKeysMap(style: MapStyle) {\n return style.map(() => true).delete('layers').delete('sources').toJS();\n }\n\n const prevKeysMap = prevStyle && (styleKeysMap(prevStyle) || {});\n const nextKeysMap = styleKeysMap(nextStyle);\n\n function propsOtherThanLayersOrSourcesDiffer() {\n const prevKeysList = Object.keys(prevKeysMap);\n const nextKeysList = Object.keys(nextKeysMap);\n if (prevKeysList.length !== nextKeysList.length) {\n return true;\n }\n // `nextStyle` and `prevStyle` should not have the same set of props.\n if (\n nextKeysList.some(\n key => prevStyle.get(key) !== nextStyle.get(key)\n // But the value of one of those props is different.\n )\n ) {\n return true;\n }\n return false;\n }\n\n const map = this._map;\n\n if (!prevStyle || propsOtherThanLayersOrSourcesDiffer()) {\n map.setStyle(nextStyle.toJS());\n return;\n }\n\n const { sourcesDiff, layersDiff } = diffStyles(prevStyle, nextStyle);\n\n // TODO: It's rather difficult to determine style diffing in the presence\n // of refs. For now, if any style update has a ref, fallback to no diffing.\n // We can come back to this case if there's a solid usecase.\n if (layersDiff.updates.some(node => node.layer.get('ref'))) {\n map.setStyle(nextStyle.toJS());\n return;\n }\n\n sourcesDiff.enter.forEach(enter =>\n map.addSource(enter.id, enter.source.toJS())\n );\n\n sourcesDiff.update.forEach(update => this._updateSource(update));\n\n sourcesDiff.exit.forEach(exit => map.removeSource(exit.id));\n\n layersDiff.exiting.forEach((exit) => {\n if (map.style.getLayer(exit.id)) {\n map.removeLayer(exit.id);\n }\n });\n\n layersDiff.updates.forEach((update) => {\n if (!update.enter) {\n // This is an old layer that needs to be updated. Remove the old layer\n // with the same id and add it back again.\n map.removeLayer(update.id);\n }\n map.addLayer(update.layer.toJS(), update.before);\n });\n }\n\n /**\n * Update Map style from newProps\n *\n * @private\n * @param {Props} oldProps\n * @param {Props} newProps\n */\n _updateMapStyle(oldProps: Props, newProps: Props): void {\n const mapStyle = newProps.mapStyle;\n const oldMapStyle = oldProps.mapStyle;\n if (mapStyle !== oldMapStyle) {\n if (Map.isMap(mapStyle)) {\n if (this.props.preventStyleDiffing) {\n this._map.setStyle(mapStyle.toJS());\n } else {\n this._setDiffStyle(oldMapStyle, mapStyle);\n }\n } else {\n this._map.setStyle(mapStyle);\n }\n this._updateQueryParams(mapStyle);\n }\n }\n\n /**\n * Update Map viewport from newProps\n *\n * @private\n * @param {Props} newProps\n */\n _updateMapViewport(newProps: Props): void {\n const map = this._map;\n const center = map.getCenter();\n\n const viewportChanged =\n newProps.latitude !== center.lat ||\n newProps.longitude !== center.lng ||\n newProps.zoom !== map.getZoom() ||\n newProps.pitch !== map.getPitch() ||\n newProps.bearing !== map.getBearing();\n\n if (viewportChanged) {\n map.flyTo({\n center: [newProps.longitude, newProps.latitude],\n zoom: newProps.zoom,\n pitch: newProps.pitch,\n bearing: newProps.bearing\n });\n }\n }\n\n /**\n * fires `onViewportChange` callback when the user interacted with the map.\n *\n * @private\n * @param {(mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent)} event\n */\n _onViewportChange(event: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent): void {\n const map = event.target;\n const { lng, lat } = map.getCenter();\n const zoom = map.getZoom();\n const pitch = map.getPitch();\n const bearing = map.getBearing();\n\n const viewport = {\n latitude: lat,\n longitude: lng,\n zoom,\n pitch,\n bearing\n };\n\n this.props.onViewportChange(viewport);\n }\n\n _getFeatures(position: [number, number], radius: number) {\n // Radius enables point features, like marker symbols, to be clicked.\n if (radius) {\n const bbox = [\n [position[0] - radius, position[1] - radius],\n [position[0] + radius, position[1] + radius]\n ];\n\n return this._map.queryRenderedFeatures(bbox, this._queryParams);\n }\n\n return this._map.queryRenderedFeatures(position, this._queryParams);\n }\n\n _onHover(event: mapboxgl.MapEvent): void {\n if (this.props.onHover) {\n const position = [event.point.x, event.point.y];\n\n /* eslint-disable no-param-reassign */\n event.features = this._getFeatures(position, this.props.clickRadius);\n /* eslint-enable no-param-reassign */\n\n if (event.features.length > 0) {\n this.props.onHover(event);\n }\n }\n }\n\n _onClick(event: mapboxgl.MapEvent): void {\n if (this.props.onClick) {\n const position = [event.point.x, event.point.y];\n\n /* eslint-disable no-param-reassign */\n event.features = this._getFeatures(position, this.props.clickRadius);\n /* eslint-enable no-param-reassign */\n\n this.props.onClick(event);\n }\n }\n\n render() {\n const { className, style } = this.props;\n\n return createElement('div', {\n ref: ref => this._container = ref,\n style,\n className\n });\n }\n}\n\nMapGL.displayName = 'MapGL';\nMapGL.defaultProps = {\n className: null,\n mapStyle: 'mapbox://styles/mapbox/light-v8',\n accessToken: null,\n preserveDrawingBuffer: false,\n onViewportChange: null,\n onClick: null,\n onHover: null,\n clickRadius: 0,\n attributionControl: true,\n preventStyleDiffing: false,\n bearing: 0,\n pitch: 0,\n onLoad: null\n};\n\nexport default MapGL;\n\n\n\n// WEBPACK FOOTER //\n// ./src/components/MapGL.js","module.exports = __WEBPACK_EXTERNAL_MODULE_3__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"mapbox-gl\"\n// module id = 3\n// module chunks = 0","module.exports = __WEBPACK_EXTERNAL_MODULE_4__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"react\"\n// module id = 4\n// module chunks = 0","/* @flow */\n\n// Copyright (c) 2015 Uber Technologies, Inc.\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport type { MapStyle, SourcesDiff, LayersDiff } from '../types';\n\nexport function diffSources(prevStyle: MapStyle, nextStyle: MapStyle): SourcesDiff {\n const prevSources = prevStyle.get('sources');\n const nextSources = nextStyle.get('sources');\n const enter = [];\n const update = [];\n const exit = [];\n const prevIds = prevSources.keySeq().toArray();\n const nextIds = nextSources.keySeq().toArray();\n prevIds.forEach((id) => {\n const nextSource = nextSources.get(id);\n if (nextSource) {\n if (!nextSource.equals(prevSources.get(id))) {\n update.push({ id, source: nextSources.get(id) });\n }\n } else {\n exit.push({ id, source: prevSources.get(id) });\n }\n });\n nextIds.forEach((id) => {\n const prevSource = prevSources.get(id);\n if (!prevSource) {\n enter.push({ id, source: nextSources.get(id) });\n }\n });\n return { enter, update, exit };\n}\n\nexport function diffLayers(prevStyle: MapStyle, nextStyle: MapStyle): LayersDiff {\n const prevLayers = prevStyle.get('layers');\n const nextLayers = nextStyle.get('layers');\n const updates = [];\n const exiting = [];\n const prevMap = {};\n const nextMap = {};\n nextLayers.forEach((layer, index) => {\n const id = layer.get('id');\n const layerImBehind = nextLayers.get(index + 1);\n nextMap[id] = {\n layer,\n id,\n // The `id` of the layer before this one.\n before: layerImBehind ? layerImBehind.get('id') : null,\n enter: true\n };\n });\n prevLayers.forEach((layer, index) => {\n const id = layer.get('id');\n const layerImBehind = prevLayers.get(index + 1);\n prevMap[id] = {\n layer,\n id,\n before: layerImBehind ? layerImBehind.get('id') : null\n };\n if (nextMap[id]) {\n // Not a new layer.\n nextMap[id].enter = false;\n } else {\n // This layer is being removed.\n exiting.push(prevMap[id]);\n }\n });\n nextLayers.reverse().forEach((layer) => {\n const id = layer.get('id');\n if (\n !prevMap[id] ||\n !prevMap[id].layer.equals(nextMap[id].layer) ||\n prevMap[id].before !== nextMap[id].before\n ) {\n // This layer is being changed.\n updates.push(nextMap[id]);\n }\n });\n return { updates, exiting };\n}\n\nexport default function diffStyle(prevStyle: MapStyle, nextStyle: MapStyle) {\n return {\n sourcesDiff: diffSources(prevStyle, nextStyle),\n layersDiff: diffLayers(prevStyle, nextStyle)\n };\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/diff-styles.js","/* @flow */\n\nimport { Map } from 'immutable';\nimport type { MapStyle } from '../types';\n\nfunction getInteractiveLayerIds(mapStyle: MapStyle): Array {\n if (Map.isMap(mapStyle)) {\n const layers = mapStyle.get('layers');\n if (layers) {\n return layers\n .filter(l => l.get('interactive'))\n .map(l => l.get('id'))\n .toJS();\n }\n }\n\n return [];\n}\n\nexport default getInteractiveLayerIds;\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/style-utils.js"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/build/bundle.f0a96127.js b/docs/build/bundle.9aa3f8fc.js similarity index 99% rename from docs/build/bundle.f0a96127.js rename to docs/build/bundle.9aa3f8fc.js index 693faff3..9ff48c9e 100644 --- a/docs/build/bundle.f0a96127.js +++ b/docs/build/bundle.9aa3f8fc.js @@ -66769,6 +66769,7 @@ var MapGL = function (_PureComponent) { } _this._onClick = _this._onClick.bind(_this); + _this._onHover = _this._onHover.bind(_this); _this._onViewportChange = _this._onViewportChange.bind(_this); return _this; } @@ -66806,6 +66807,7 @@ var MapGL = function (_PureComponent) { } map.on('click', this._onClick); + map.on('mousemove', this._onHover); map.on('dragend', this._onViewportChange); map.on('zoomend', this._onViewportChange); @@ -67097,6 +67099,21 @@ var MapGL = function (_PureComponent) { return this._map.queryRenderedFeatures(position, this._queryParams); } + }, { + key: '_onHover', + value: function _onHover(event) { + if (this.props.onHover) { + var position = [event.point.x, event.point.y]; + + /* eslint-disable no-param-reassign */ + event.features = this._getFeatures(position, this.props.clickRadius); + /* eslint-enable no-param-reassign */ + + if (event.features.length > 0) { + this.props.onHover(event); + } + } + } }, { key: '_onClick', value: function _onClick(event) { @@ -67105,6 +67122,7 @@ var MapGL = function (_PureComponent) { /* eslint-disable no-param-reassign */ event.features = this._getFeatures(position, this.props.clickRadius); + /* eslint-enable no-param-reassign */ this.props.onClick(event); } @@ -67140,6 +67158,7 @@ MapGL.defaultProps = { preserveDrawingBuffer: false, onViewportChange: null, onClick: null, + onHover: null, clickRadius: 0, attributionControl: true, preventStyleDiffing: false, @@ -67852,6 +67871,70 @@ module.exports = { }, 'tags': {} }, + 'onHover': { + 'flowType': { + 'name': 'signature', + 'type': 'function', + 'raw': '(event: mapboxgl.MapEvent) => mixed', + 'signature': { + 'arguments': [{ + 'name': 'event', + 'type': { 'name': 'unknown' } + }], + 'return': { 'name': 'mixed' } + } + }, + 'required': true, + 'description': 'Called when the map is hovered over.', + 'defaultValue': { + 'value': 'null', + 'computed': false + }, + 'tags': { + 'callback': [{ + 'title': 'callback', + 'description': null + }], + 'param': [ + { + 'title': 'param', + 'description': 'The mouse event.', + 'type': { + 'type': 'NameExpression', + 'name': 'Object' + }, + 'name': 'event' + }, + { + 'title': 'param', + 'description': 'The coordinates of the pointer', + 'type': { + 'type': 'ArrayType', + 'elements': [ + { + 'type': 'NameExpression', + 'name': 'Number' + }, + { + 'type': 'NameExpression', + 'name': 'Number' + } + ] + }, + 'name': 'event.lngLat' + }, + { + 'title': 'param', + 'description': 'The features under the pointer, using Mapbox\'s\nqueryRenderedFeatures API:\nhttps://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures\nTo make a layer interactive, set the `interactive` property in the\nlayer style to `true`. See Mapbox\'s style spec\nhttps://www.mapbox.com/mapbox-gl-style-spec/#layer-interactive', + 'type': { + 'type': 'NameExpression', + 'name': 'Array' + }, + 'name': 'event.features' + } + ] + } + }, 'onClick': { 'flowType': { 'name': 'signature', @@ -68032,11 +68115,11 @@ module.exports = [ }, { 'type': 'markdown', - 'content': '## onClick' + 'content': '## onHover & onClick' }, { 'type': 'code', - 'content': 'const Immutable = require(\'immutable\');\nconst accessToken = require(\'../utils/accessToken\');\n\nconst onClick = (event) => {\n console.log(\'features\', event.features);\n};\n\nconst mapStyle = Immutable.fromJS({\n version: 8,\n sources: {\n marker: {\n type: \'geojson\',\n data: {\n type: \'Feature\',\n geometry: { type: \'Point\', coordinates: [0, 0] },\n properties: {}\n }\n }\n },\n layers: [{\n id: \'marker\',\n type: \'circle\',\n source: \'marker\',\n interactive: true,\n paint: {\n \'circle-radius\': 16,\n \'circle-color\': \'#f00\'\n }\n }]\n});\n\n', + 'content': 'const Immutable = require(\'immutable\');\nconst accessToken = require(\'../utils/accessToken\');\n\nconst mapStyle = Immutable.fromJS({\n version: 8,\n sources: {\n marker: {\n type: \'geojson\',\n data: {\n type: \'FeatureCollection\',\n features: [\n { type: \'Feature\', geometry: { type: \'Point\', coordinates: [10, 10] } },\n { type: \'Feature\', geometry: { type: \'Point\', coordinates: [10, -10] } },\n { type: \'Feature\', geometry: { type: \'Point\', coordinates: [-10, -10] } },\n { type: \'Feature\', geometry: { type: \'Point\', coordinates: [-10, 10] } }\n ]\n }\n }\n },\n layers: [{\n id: \'marker\',\n type: \'circle\',\n source: \'marker\',\n interactive: true, // this will make layer interactive\n paint: {\n \'circle-radius\': 16,\n \'circle-color\': \'#f00\'\n }\n }]\n});\n\nconst onHover = (event) => {\n console.log(\'hover over features\', event.features);\n};\n\nconst onClick = (event) => {\n console.log(\'click on features\', event.features);\n};\n\n', 'settings': {}, 'evalInContext': evalInContext } diff --git a/docs/index.html b/docs/index.html index 75f23333..d1286f99 100644 --- a/docs/index.html +++ b/docs/index.html @@ -7,5 +7,5 @@
- + diff --git a/package-lock.json b/package-lock.json index f934ce25..2c3dee60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,6 +34,22 @@ "integrity": "sha1-wd5CkwgUJNo6wwwjr6hQrxAZu1Q=", "dev": true }, + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, + "JSV": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz", + "integrity": "sha1-0Hf2glVx+CEy+d/67Vh7QCn+/1c=", + "dev": true + }, "abab": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.3.tgz", @@ -615,15 +631,151 @@ } }, "babel-eslint": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-7.2.3.tgz", - "integrity": "sha1-sv4tgBJkcPXBlELcdXJTqJdxCCc=", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-8.0.0.tgz", + "integrity": "sha512-tN1B3adZ3tw8pr9oGsZ18iKCbdKBSvsn9ab6cGdbED+61LpGLhIVcf76eh59XejbdRLTBe+OYezxmYIaTgPiYA==", "dev": true, "requires": { - "babel-code-frame": "6.22.0", - "babel-traverse": "6.25.0", - "babel-types": "6.25.0", - "babylon": "6.17.4" + "babel-code-frame": "7.0.0-beta.0", + "babel-traverse": "7.0.0-beta.0", + "babel-types": "7.0.0-beta.0", + "babylon": "7.0.0-beta.22" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.0" + } + }, + "babel-code-frame": { + "version": "7.0.0-beta.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-7.0.0-beta.0.tgz", + "integrity": "sha512-/xr1ADm5bnTjjN+xwoXb7lF4v2rnxMzNZzFU7h8SxB+qB6+IqSTOOqVcpaPTUC2Non/MbQxS3OIZnJpQ2X21aQ==", + "dev": true, + "requires": { + "chalk": "2.1.0", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + } + }, + "babel-helper-function-name": { + "version": "7.0.0-beta.0", + "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-7.0.0-beta.0.tgz", + "integrity": "sha512-DaQccFBBWBEzMdqbKmNXamY0m1yLHJGOdbbEsNoGdJrrU7wAF3wwowtDDPzF0ZT3SqJXPgZW/P2kgBX9moMuAA==", + "dev": true, + "requires": { + "babel-helper-get-function-arity": "7.0.0-beta.0", + "babel-template": "7.0.0-beta.0", + "babel-traverse": "7.0.0-beta.0", + "babel-types": "7.0.0-beta.0" + } + }, + "babel-helper-get-function-arity": { + "version": "7.0.0-beta.0", + "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-7.0.0-beta.0.tgz", + "integrity": "sha512-csqAic15/2Vm1951nJxkkL9K8E6ojyNF/eAOjk7pqJlO8kvgrccGNFCV9eDwcGHDPe5AjvJGwVSAcQ5fit9wuA==", + "dev": true, + "requires": { + "babel-types": "7.0.0-beta.0" + } + }, + "babel-messages": { + "version": "7.0.0-beta.0", + "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-7.0.0-beta.0.tgz", + "integrity": "sha512-eXdShsm9ZTh9AQhlIaAn6HR3xWpxCnK9ZwIDA9QyjnwTgMctGxHHflw4b4RJ3/ZjTL0Vrmvm0tQXPkp49mTAUw==", + "dev": true + }, + "babel-template": { + "version": "7.0.0-beta.0", + "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-7.0.0-beta.0.tgz", + "integrity": "sha512-tmdH+MmmU0F6Ur8humpevSmFzYKbrN3Oru0g5Qyg4R6+sxjnzZmnvzUbsP0aKMr7tB0Ua6xhEb9arKTOsEMkyA==", + "dev": true, + "requires": { + "babel-traverse": "7.0.0-beta.0", + "babel-types": "7.0.0-beta.0", + "babylon": "7.0.0-beta.22", + "lodash": "4.17.4" + } + }, + "babel-traverse": { + "version": "7.0.0-beta.0", + "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-7.0.0-beta.0.tgz", + "integrity": "sha512-IKzuTqUcQtMRZ0Vv5RjIrGGj33eBKmNTNeRexWSyjPPuAciyNkva1rt7WXPfHfkb+dX7coRAIUhzeTUEzhnwdA==", + "dev": true, + "requires": { + "babel-code-frame": "7.0.0-beta.0", + "babel-helper-function-name": "7.0.0-beta.0", + "babel-messages": "7.0.0-beta.0", + "babel-types": "7.0.0-beta.0", + "babylon": "7.0.0-beta.22", + "debug": "3.0.1", + "globals": "10.1.0", + "invariant": "2.2.2", + "lodash": "4.17.4" + } + }, + "babel-types": { + "version": "7.0.0-beta.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-7.0.0-beta.0.tgz", + "integrity": "sha512-rJc2kV9iPJGLlqIY71AM3nPcdkoeLRCDuR07GFgfd3lFl4TsBQq76TxYQQIZ2MONg1HpsqmuoCXr9aZ1Oa4wYw==", + "dev": true, + "requires": { + "esutils": "2.0.2", + "lodash": "4.17.4", + "to-fast-properties": "2.0.0" + } + }, + "babylon": { + "version": "7.0.0-beta.22", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.22.tgz", + "integrity": "sha512-Yl7iT8QGrS8OfR7p6R12AJexQm+brKwrryai4VWZ7NHUbPoZ5al3+klhvl/14shXZiLa7uK//OIFuZ1/RKHgoA==", + "dev": true + }, + "chalk": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", + "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.4.0" + } + }, + "debug": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.0.1.tgz", + "integrity": "sha512-6nVc6S36qbt/mutyt+UGMnawAMrPDZUPQjRZI3FS9tCtDRhvxJbK79unYBLPi+z5SLXQ3ftoVBFCblQtNSls8w==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "globals": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-10.1.0.tgz", + "integrity": "sha1-RCWhiBvg0za0qCOoKnvnJdXdmHw=", + "dev": true + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + } } }, "babel-generator": { @@ -2554,8 +2706,8 @@ "integrity": "sha1-4ye1MZThp61dxjR57pCZpSsCSGU=", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.1", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.1.1", @@ -2584,8 +2736,8 @@ "integrity": "sha512-8od6g684Fhi5Vpp4ABRv/RBsW1AY6wSHbJHEK6FGTv+8jvAAnlABniZu/FVmX9TcirkHepaEsa1QGkRvbg0CKw==", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.1", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.1.1", @@ -5427,14 +5579,6 @@ } } }, - "string_decoder": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, "string-width": { "version": "1.0.2", "bundled": true, @@ -5445,6 +5589,14 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, "stringstream": { "version": "0.0.5", "bundled": true, @@ -8198,16 +8350,6 @@ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -8280,12 +8422,6 @@ "warning": "3.0.0" } }, - "JSV": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz", - "integrity": "sha1-0Hf2glVx+CEy+d/67Vh7QCn+/1c=", - "dev": true - }, "jsx-ast-utils": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz", @@ -12498,15 +12634,6 @@ "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -12518,6 +12645,15 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringify-entities": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-1.3.1.tgz", diff --git a/src/components/MapGL.js b/src/components/MapGL.js index 58122aa5..31223860 100644 --- a/src/components/MapGL.js +++ b/src/components/MapGL.js @@ -43,18 +43,32 @@ type Props = { */ onViewportChange: (viewport: Viewport) => mixed, - /** - * Called when the map is clicked. - * @callback - * @param {Object} event - The mouse event. - * @param {[Number, Number]} event.lngLat - The coordinates of the pointer - * @param {Array} event.features - The features under the pointer, using Mapbox's - * queryRenderedFeatures API: - * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures - * To make a layer interactive, set the `interactive` property in the - * layer style to `true`. See Mapbox's style spec - * https://www.mapbox.com/mapbox-gl-style-spec/#layer-interactive - */ + /** + * Called when the map is hovered over. + * @callback + * @param {Object} event - The mouse event. + * @param {[Number, Number]} event.lngLat - The coordinates of the pointer + * @param {Array} event.features - The features under the pointer, using Mapbox's + * queryRenderedFeatures API: + * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures + * To make a layer interactive, set the `interactive` property in the + * layer style to `true`. See Mapbox's style spec + * https://www.mapbox.com/mapbox-gl-style-spec/#layer-interactive + */ + onHover: (event: mapboxgl.MapEvent) => mixed, + + /** + * Called when the map is clicked. + * @callback + * @param {Object} event - The mouse event. + * @param {[Number, Number]} event.lngLat - The coordinates of the pointer + * @param {Array} event.features - The features under the pointer, using Mapbox's + * queryRenderedFeatures API: + * https://www.mapbox.com/mapbox-gl-js/api/#Map#queryRenderedFeatures + * To make a layer interactive, set the `interactive` property in the + * layer style to `true`. See Mapbox's style spec + * https://www.mapbox.com/mapbox-gl-style-spec/#layer-interactive + */ onClick: (event: mapboxgl.MapEvent) => mixed, /** Radius to detect features around a clicked point. Defaults to 0. */ @@ -110,6 +124,7 @@ class MapGL extends PureComponent { } this._onClick = this._onClick.bind(this); + this._onHover = this._onHover.bind(this); this._onViewportChange = this._onViewportChange.bind(this); } @@ -146,6 +161,7 @@ class MapGL extends PureComponent { } map.on('click', this._onClick); + map.on('mousemove', this._onHover); map.on('dragend', this._onViewportChange); map.on('zoomend', this._onViewportChange); @@ -415,12 +431,27 @@ class MapGL extends PureComponent { return this._map.queryRenderedFeatures(position, this._queryParams); } + _onHover(event: mapboxgl.MapEvent): void { + if (this.props.onHover) { + const position = [event.point.x, event.point.y]; + + /* eslint-disable no-param-reassign */ + event.features = this._getFeatures(position, this.props.clickRadius); + /* eslint-enable no-param-reassign */ + + if (event.features.length > 0) { + this.props.onHover(event); + } + } + } + _onClick(event: mapboxgl.MapEvent): void { if (this.props.onClick) { const position = [event.point.x, event.point.y]; /* eslint-disable no-param-reassign */ event.features = this._getFeatures(position, this.props.clickRadius); + /* eslint-enable no-param-reassign */ this.props.onClick(event); } @@ -445,6 +476,7 @@ MapGL.defaultProps = { preserveDrawingBuffer: false, onViewportChange: null, onClick: null, + onHover: null, clickRadius: 0, attributionControl: true, preventStyleDiffing: false, diff --git a/src/components/README.md b/src/components/README.md index 0d9d799e..947aabf9 100644 --- a/src/components/README.md +++ b/src/components/README.md @@ -75,25 +75,25 @@ if (!state.mapStyle) { /> ``` -## onClick +## onHover & onClick ```jsx const Immutable = require('immutable'); const accessToken = require('../utils/accessToken'); -const onClick = (event) => { - console.log('features', event.features); -}; - const mapStyle = Immutable.fromJS({ version: 8, sources: { marker: { type: 'geojson', data: { - type: 'Feature', - geometry: { type: 'Point', coordinates: [0, 0] }, - properties: {} + type: 'FeatureCollection', + features: [ + { type: 'Feature', geometry: { type: 'Point', coordinates: [10, 10] } }, + { type: 'Feature', geometry: { type: 'Point', coordinates: [10, -10] } }, + { type: 'Feature', geometry: { type: 'Point', coordinates: [-10, -10] } }, + { type: 'Feature', geometry: { type: 'Point', coordinates: [-10, 10] } } + ] } } }, @@ -101,7 +101,7 @@ const mapStyle = Immutable.fromJS({ id: 'marker', type: 'circle', source: 'marker', - interactive: true, + interactive: true, // this will make layer interactive paint: { 'circle-radius': 16, 'circle-color': '#f00' @@ -109,13 +109,22 @@ const mapStyle = Immutable.fromJS({ }] }); +const onHover = (event) => { + console.log('hover over features', event.features); +}; + +const onClick = (event) => { + console.log('click on features', event.features); +}; + ``` \ No newline at end of file