Removing ignored files

This commit is contained in:
Christos committed 2017-09-04 14:02:16 +03:00
1 parent e58e2488d0
commit 16b16f74bd
9 files changed
+7 -1109

No files matched your search

+2 -2
View File
@@ -36,6 +36,6 @@ node_modules
key.txt
#remove dist and iib
dist
dist/*
lib
lib/*
-596
View File
@@ -1,596 +0,0 @@
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("react-leaflet"), require("google-maps"));
else if(typeof define === 'function' && define.amd)
define(["react", "react-leaflet", "google-maps"], factory);
else if(typeof exports === 'object')
exports["ReactLeaflet"] = factory(require("react"), require("react-leaflet"), require("google-maps"));
else
root["ReactLeaflet"] = factory(root["React"], root[undefined], root["GoogleMapsLoader"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_5__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GoogleLayer = undefined;
var _Google = __webpack_require__(1);
var _Google2 = _interopRequireDefault(_Google);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.GoogleLayer = _Google2.default;
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _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; }; }();
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _reactLeaflet = __webpack_require__(3);
var _leaflet = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
var GoogleLayer = function (_GridLayer) {
_inherits(GoogleLayer, _GridLayer);
function GoogleLayer() {
_classCallCheck(this, GoogleLayer);
return _possibleConstructorReturn(this, (GoogleLayer.__proto__ || Object.getPrototypeOf(GoogleLayer)).apply(this, arguments));
}
_createClass(GoogleLayer, [{
key: 'componentWillMount',
value: function componentWillMount() {
_get(GoogleLayer.prototype.__proto__ || Object.getPrototypeOf(GoogleLayer.prototype), 'componentWillMount', this).call(this);
var _props = this.props,
_map = _props.map,
googlekey = _props.googlekey,
maptype = _props.maptype,
asclientid = _props.asclientid,
props = _objectWithoutProperties(_props, ['map', 'googlekey', 'maptype', 'asclientid']);
this.leafletElement = new L.gridLayer.googleMutant(this.props);
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps) {
var _props2 = this.props,
opacity = _props2.opacity,
zIndex = _props2.zIndex;
if (opacity !== prevProps.opacity) {
this.leafletElement.setOpacity(opacity);
}
if (zIndex !== prevProps.zIndex) {
this.leafletElement.setZIndex(zIndex);
}
}
}]);
return GoogleLayer;
}(_reactLeaflet.GridLayer);
GoogleLayer.propTypes = {
googlekey: _react.PropTypes.string.isRequired,
maptype: _react.PropTypes.string,
asclientid: _react.PropTypes.bool
};
exports.default = GoogleLayer;
/***/ },
/* 2 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
/***/ },
/* 3 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_3__;
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
// Based on https://github.com/shramov/leaflet-plugins
// GridLayer like https://avinmathew.com/leaflet-and-google-maps/ , but using MutationObserver instead of jQuery
var GoogleMapsLoader = __webpack_require__(5);
GoogleMapsLoader.VERSION = '3.18';
// 🍂class GridLayer.GoogleMutant
// 🍂extends GridLayer
L.GridLayer.GoogleMutant = L.GridLayer.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
subdomains: 'abc',
errorTileUrl: '',
attribution: '', // The mutant container will add its own attribution anyways.
opacity: 1,
continuousWorld: false,
noWrap: false,
// 🍂option type: String = 'roadmap'
// Google's map type. Valid values are 'roadmap', 'satellite' or 'terrain'. 'hybrid' is not really supported.
type: 'satellite',
maxNativeZoom: 21
},
initialize: function initialize(options) {
L.GridLayer.prototype.initialize.call(this, options);
var self = this;
if (options.asclientid) {
GoogleMapsLoader.CLIENT = options.googlekey;
} else {
GoogleMapsLoader.KEY = options.googlekey;
}
self._type = options.maptype || 'SATELLITE';
GoogleMapsLoader.load(function (_google) {
google = _google;
console.log('I just loaded google maps api');
self._ready = true;
//self._initMapObject();
// self.
self._initMutant();
self._update();
//this._ready = google.maps.Map !== undefined;
//if (!this._ready) L.Google.asyncWait.push(this);
});
// Couple data structures indexed by tile key
this._tileCallbacks = {}; // Callbacks for promises for tiles that are expected
this._freshTiles = {}; // Tiles from the mutant which haven't been requested yet
this._imagesPerTile = self._type === 'hybrid' ? 2 : 1;
this.createTile = self._type === 'hybrid' ? this._createMultiTile : this._createSingleTile;
},
onAdd: function onAdd(map) {
L.GridLayer.prototype.onAdd.call(this, map);
this._initMutantContainer();
// this._GAPIPromise.then(function () {
if (this._ready) {
this._map = map;
this._initMutant();
map.on('viewreset', this._reset, this);
map.on('move', this._update, this);
map.on('zoomend', this._handleZoomAnim, this);
map.on('resize', this._resize, this);
//20px instead of 1em to avoid a slight overlap with google's attribution
map._controlCorners.bottomright.style.marginBottom = '20px';
this._reset();
this._update();
}
//}.bind(this));
},
onRemove: function onRemove(map) {
L.GridLayer.prototype.onRemove.call(this, map);
map._container.removeChild(this._mutantContainer);
this._mutantContainer = undefined;
map.off('viewreset', this._reset, this);
map.off('move', this._update, this);
map.off('zoomend', this._handleZoomAnim, this);
map.off('resize', this._resize, this);
map._controlCorners.bottomright.style.marginBottom = '0em';
},
getAttribution: function getAttribution() {
return this.options.attribution;
},
setOpacity: function setOpacity(opacity) {
this.options.opacity = opacity;
if (opacity < 1) {
L.DomUtil.setOpacity(this._mutantContainer, opacity);
}
},
setElementSize: function setElementSize(e, size) {
e.style.width = size.x + 'px';
e.style.height = size.y + 'px';
},
_initMutantContainer: function _initMutantContainer() {
if (!this._mutantContainer) {
this._mutantContainer = L.DomUtil.create('div', 'leaflet-google-mutant leaflet-top leaflet-left');
this._mutantContainer.id = '_MutantContainer_' + L.Util.stamp(this._mutantContainer);
// this._mutantContainer.style.zIndex = 'auto';
this._mutantContainer.style.pointerEvents = 'none';
this._map.getContainer().appendChild(this._mutantContainer);
}
this.setOpacity(this.options.opacity);
this.setElementSize(this._mutantContainer, this._map.getSize());
this._attachObserver(this._mutantContainer);
},
_initMutant: function _initMutant() {
if (!this._ready || !this._mutantContainer) return;
this._mutantCenter = new google.maps.LatLng(0, 0);
var map = new google.maps.Map(this._mutantContainer, {
center: this._mutantCenter,
zoom: 0,
tilt: 0,
mapTypeId: google.maps.MapTypeId[this._type],
disableDefaultUI: true,
keyboardShortcuts: false,
draggable: false,
disableDoubleClickZoom: true,
scrollwheel: false,
streetViewControl: false,
styles: this.options.styles || {},
backgroundColor: 'transparent'
});
this._mutant = map;
// 🍂event spawned
// Fired when the mutant has been created.
this.fire('spawned', {
mapObject: map
});
},
_attachObserver: function _attachObserver(node) {
// console.log('Gonna observe', node);
var observer = new MutationObserver(this._onMutations.bind(this));
// pass in the target node, as well as the observer options
observer.observe(node, {
childList: true,
subtree: true
});
},
_onMutations: function _onMutations(mutations) {
for (var i = 0; i < mutations.length; ++i) {
var mutation = mutations[i];
for (var j = 0; j < mutation.addedNodes.length; ++j) {
var node = mutation.addedNodes[j];
if (node instanceof HTMLImageElement) {
this._onMutatedImage(node);
} else if (node instanceof HTMLElement) {
Array.prototype.forEach.call(node.querySelectorAll('img'), this._onMutatedImage.bind(this));
}
}
}
},
// Only images which 'src' attrib match this will be considered for moving around.
// Looks like some kind of string-based protobuf, maybe??
// Only the roads (and terrain, and vector-based stuff) match this pattern
_roadRegexp: /!1i(\d+)!2i(\d+)!3i(\d+)!/,
// On the other hand, raster imagery matches this other pattern
_satRegexp: /x=(\d+)&y=(\d+)&z=(\d+)/,
// On small viewports, when zooming in/out, a static image is requested
// This will not be moved around, just removed from the DOM.
_staticRegExp: /StaticMapService\.GetMapImage/,
_onMutatedImage: function _onMutatedImage(imgNode) {
// if (imgNode.src) {
// console.log('caught mutated image: ', imgNode.src);
// }
var coords;
var match = imgNode.src.match(this._roadRegexp);
var sublayer, parent;
if (match) {
coords = {
z: match[1],
x: match[2],
y: match[3]
};
if (this._imagesPerTile > 1) {
imgNode.style.zIndex = 1;
}
sublayer = 1;
} else {
match = imgNode.src.match(this._satRegexp);
if (match) {
coords = {
x: match[1],
y: match[2],
z: match[3]
};
}
// imgNode.style.zIndex = 0;
sublayer = 0;
}
if (coords) {
var key = this._tileCoordsToKey(coords);
imgNode.style.position = 'absolute';
if (this._imagesPerTile > 1) {
key += '/' + sublayer;
}
if (key in this._tileCallbacks && this._tileCallbacks[key]) {
// console.log('Fullfilling callback ', key);
this._tileCallbacks[key].pop()(imgNode);
if (!this._tileCallbacks[key].length) {
delete this._tileCallbacks[key];
}
} else {
// console.log('Caching for later', key);
parent = imgNode.parentNode;
if (parent) {
parent.removeChild(imgNode);
parent.removeChild = L.Util.falseFn;
// imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
}
if (key in this._freshTiles) {
this._freshTiles[key].push(imgNode);
} else {
this._freshTiles[key] = [imgNode];
}
}
} else if (imgNode.src.match(this._staticRegExp)) {
parent = imgNode.parentNode;
if (parent) {
// Remove the image, but don't store it anywhere.
// Image needs to be replaced instead of removed, as the container
// seems to be reused.
imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
}
}
},
// This will be used as this.createTile for 'roadmap', 'sat', 'terrain'
_createSingleTile: function createTile(coords, done) {
var key = this._tileCoordsToKey(coords);
// console.log('Need:', key);
if (key in this._freshTiles) {
var tile = this._freshTiles[key].pop();
if (!this._freshTiles[key].length) {
delete this._freshTiles[key];
}
L.Util.requestAnimFrame(done);
// console.log('Got ', key, ' from _freshTiles');
return tile;
} else {
var tileContainer = L.DomUtil.create('div');
this._tileCallbacks[key] = this._tileCallbacks[key] || [];
this._tileCallbacks[key].push(function (c /*, k*/) {
return function (imgNode) {
var parent = imgNode.parentNode;
if (parent) {
parent.removeChild(imgNode);
parent.removeChild = L.Util.falseFn;
// imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
}
c.appendChild(imgNode);
done();
// console.log('Sent ', k, ' to _tileCallbacks');
}.bind(this);
}.bind(this)(tileContainer /*, key*/));
return tileContainer;
}
},
// This will be used as this.createTile for 'hybrid'
_createMultiTile: function createTile(coords, done) {
var key = this._tileCoordsToKey(coords);
var tileContainer = L.DomUtil.create('div');
tileContainer.dataset.pending = this._imagesPerTile;
for (var i = 0; i < this._imagesPerTile; i++) {
var key2 = key + '/' + i;
if (key2 in this._freshTiles) {
tileContainer.appendChild(this._freshTiles[key2].pop());
if (!this._freshTiles[key2].length) {
delete this._freshTiles[key2];
}
tileContainer.dataset.pending--;
// console.log('Got ', key2, ' from _freshTiles');
} else {
this._tileCallbacks[key2] = this._tileCallbacks[key2] || [];
this._tileCallbacks[key2].push(function (c /*, k2*/) {
return function (imgNode) {
var parent = imgNode.parentNode;
if (parent) {
parent.removeChild(imgNode);
parent.removeChild = L.Util.falseFn;
// imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
}
c.appendChild(imgNode);
c.dataset.pending--;
if (!parseInt(c.dataset.pending)) {
done();
}
// console.log('Sent ', k2, ' to _tileCallbacks, still ', c.dataset.pending, ' images to go');
}.bind(this);
}.bind(this)(tileContainer /*, key2*/));
}
}
if (!parseInt(tileContainer.dataset.pending)) {
L.Util.requestAnimFrame(done);
}
return tileContainer;
},
_checkZoomLevels: function _checkZoomLevels() {
//setting the zoom level on the Google map may result in a different zoom level than the one requested
//(it won't go beyond the level for which they have data).
// verify and make sure the zoom levels on both Leaflet and Google maps are consistent
if (this._map.getZoom() !== undefined && this._mutant.getZoom() !== this._map.getZoom()) {
//zoom levels are out of sync. Set the leaflet zoom level to match the google one
this._map.setZoom(this._mutant.getZoom());
}
},
_reset: function _reset() {
this._initContainer();
},
_update: function _update() {
L.GridLayer.prototype._update.call(this);
if (!this._mutant) return;
var center = this._map.getCenter();
var _center = new google.maps.LatLng(center.lat, center.lng);
this._mutant.setCenter(_center);
var zoom = this._map.getZoom();
if (zoom !== undefined) {
this._mutant.setZoom(Math.round(this._map.getZoom()));
}
},
_resize: function _resize() {
var size = this._map.getSize();
if (this._mutantContainer.style.width === size.x && this._mutantContainer.style.height === size.y) return;
this.setElementSize(this._mutantContainer, size);
if (!this._mutant) return;
google.maps.event.trigger(this._mutant, 'resize');
},
_handleZoomAnim: function _handleZoomAnim() {
var center = this._map.getCenter();
var _center = new google.maps.LatLng(center.lat, center.lng);
this._mutant.setCenter(_center);
this._mutant.setZoom(Math.round(this._map.getZoom()));
},
// Agressively prune _freshtiles when a tile with the same key is removed,
// this prevents a problem where Leaflet keeps a loaded tile longer than
// GMaps, so that GMaps makes two requests but Leaflet only consumes one,
// polluting _freshTiles with stale data.
_removeTile: function _removeTile(key) {
if (this._imagesPerTile > 1) {
for (var i = 0; i < this._imagesPerTile; i++) {
var key2 = key + '/' + i;
if (key2 in this._freshTiles) {
delete this._freshTiles[key2];
}
// console.log('Pruned spurious hybrid _freshTiles');
}
} else {
if (key in this._freshTiles) {
delete this._freshTiles[key];
// console.log('Pruned spurious _freshTiles', key);
}
}
return L.GridLayer.prototype._removeTile.call(this, key);
}
});
// 🍂factory gridLayer.googleMutant(options)
// Returns a new `GridLayer.GoogleMutant` given its options
L.gridLayer.googleMutant = function (options) {
return new L.GridLayer.GoogleMutant(options);
};
/***/ },
/* 5 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_5__;
/***/ }
/******/ ])
});
;
-1
View File
@@ -1 +0,0 @@
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("google-maps"),require("react"),require("react-leaflet")):"function"==typeof define&&define.amd?define(["google-maps","react","react-leaflet"],e):"object"==typeof exports?exports.ReactLeaflet=e(require("google-maps"),require("react"),require("react-leaflet")):t.ReactLeaflet=e(t.GoogleMapsLoader,t.React,t[void 0])}(this,function(t,e,i){return function(t){function e(o){if(i[o])return i[o].exports;var n=i[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.GoogleLayer=void 0;var n=i(1),r=o(n);e.GoogleLayer=r.default},function(t,e,i){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){var i={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(i[o]=t[o]);return i}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var l=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),h=function t(e,i,o){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,i);if(void 0===n){var r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,o)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(o)},p=i(4),u=(o(p),i(5)),c=(i(2),function(t){function e(){return r(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return s(e,t),l(e,[{key:"componentWillMount",value:function(){h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"componentWillMount",this).call(this);var t=this.props;t.map,t.googlekey,t.maptype,t.asclientid,n(t,["map","googlekey","maptype","asclientid"]);this.leafletElement=new L.gridLayer.googleMutant(this.props)}},{key:"componentDidUpdate",value:function(t){var e=this.props,i=e.opacity,o=e.zIndex;i!==t.opacity&&this.leafletElement.setOpacity(i),o!==t.zIndex&&this.leafletElement.setZIndex(o)}}]),e}(u.GridLayer));c.propTypes={googlekey:p.PropTypes.string.isRequired,maptype:p.PropTypes.string,asclientid:p.PropTypes.bool},e.default=c},function(t,e,i){"use strict";var o=i(3);o.VERSION="3.18",L.GridLayer.GoogleMutant=L.GridLayer.extend({includes:L.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",opacity:1,continuousWorld:!1,noWrap:!1,type:"satellite",maxNativeZoom:21},initialize:function(t){L.GridLayer.prototype.initialize.call(this,t);var e=this;t.asclientid?o.CLIENT=t.googlekey:o.KEY=t.googlekey,e._type=t.maptype||"SATELLITE",o.load(function(t){google=t,console.log("I just loaded google maps api"),e._ready=!0,e._initMutant(),e._update()}),this._tileCallbacks={},this._freshTiles={},this._imagesPerTile="hybrid"===e._type?2:1,this.createTile="hybrid"===e._type?this._createMultiTile:this._createSingleTile},onAdd:function(t){L.GridLayer.prototype.onAdd.call(this,t),this._initMutantContainer(),this._ready&&(this._map=t,this._initMutant(),t.on("viewreset",this._reset,this),t.on("move",this._update,this),t.on("zoomend",this._handleZoomAnim,this),t.on("resize",this._resize,this),t._controlCorners.bottomright.style.marginBottom="20px",this._reset(),this._update())},onRemove:function(t){L.GridLayer.prototype.onRemove.call(this,t),t._container.removeChild(this._mutantContainer),this._mutantContainer=void 0,t.off("viewreset",this._reset,this),t.off("move",this._update,this),t.off("zoomend",this._handleZoomAnim,this),t.off("resize",this._resize,this),t._controlCorners.bottomright.style.marginBottom="0em"},getAttribution:function(){return this.options.attribution},setOpacity:function(t){this.options.opacity=t,t<1&&L.DomUtil.setOpacity(this._mutantContainer,t)},setElementSize:function(t,e){t.style.width=e.x+"px",t.style.height=e.y+"px"},_initMutantContainer:function(){this._mutantContainer||(this._mutantContainer=L.DomUtil.create("div","leaflet-google-mutant leaflet-top leaflet-left"),this._mutantContainer.id="_MutantContainer_"+L.Util.stamp(this._mutantContainer),this._mutantContainer.style.pointerEvents="none",this._map.getContainer().appendChild(this._mutantContainer)),this.setOpacity(this.options.opacity),this.setLine truncated
+1 -1
View File
@@ -2,7 +2,7 @@ import React from 'react';
import { Map, TileLayer, LayersControl } from 'react-leaflet'
import {GoogleLayer} from '../src'
const { BaseLayer} = LayersControl;
const key = 'Your Key goes here';
const key = 'AIzaSyDEG4lyorD61vnJoAHG0FkQERZ-McElZyg';
const terrain = 'TERRAIN';
const road = 'ROADMAP';
const satellite = 'SATELLITE';
-76
View File
@@ -1,76 +0,0 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _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; }; }();
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactLeaflet = require('react-leaflet');
var _leaflet = require('./leaflet.google');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
var GoogleLayer = function (_GridLayer) {
_inherits(GoogleLayer, _GridLayer);
function GoogleLayer() {
_classCallCheck(this, GoogleLayer);
return _possibleConstructorReturn(this, (GoogleLayer.__proto__ || Object.getPrototypeOf(GoogleLayer)).apply(this, arguments));
}
_createClass(GoogleLayer, [{
key: 'componentWillMount',
value: function componentWillMount() {
_get(GoogleLayer.prototype.__proto__ || Object.getPrototypeOf(GoogleLayer.prototype), 'componentWillMount', this).call(this);
var _props = this.props,
_map = _props.map,
googlekey = _props.googlekey,
maptype = _props.maptype,
asclientid = _props.asclientid,
props = _objectWithoutProperties(_props, ['map', 'googlekey', 'maptype', 'asclientid']);
this.leafletElement = new L.gridLayer.googleMutant(this.props);
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps) {
var _props2 = this.props,
opacity = _props2.opacity,
zIndex = _props2.zIndex;
if (opacity !== prevProps.opacity) {
this.leafletElement.setOpacity(opacity);
}
if (zIndex !== prevProps.zIndex) {
this.leafletElement.setZIndex(zIndex);
}
}
}]);
return GoogleLayer;
}(_reactLeaflet.GridLayer);
GoogleLayer.propTypes = {
googlekey: _react.PropTypes.string.isRequired,
maptype: _react.PropTypes.string,
asclientid: _react.PropTypes.bool
};
exports.default = GoogleLayer;
-14
View File
@@ -1,14 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GoogleLayer = undefined;
var _Google = require("./Google");
var _Google2 = _interopRequireDefault(_Google);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.GoogleLayer = _Google2.default;
-417
View File
@@ -1,417 +0,0 @@
'use strict';
// Based on https://github.com/shramov/leaflet-plugins
// GridLayer like https://avinmathew.com/leaflet-and-google-maps/ , but using MutationObserver instead of jQuery
var GoogleMapsLoader = require('google-maps');
GoogleMapsLoader.VERSION = '3.18';
// 🍂class GridLayer.GoogleMutant
// 🍂extends GridLayer
L.GridLayer.GoogleMutant = L.GridLayer.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
subdomains: 'abc',
errorTileUrl: '',
attribution: '', // The mutant container will add its own attribution anyways.
opacity: 1,
continuousWorld: false,
noWrap: false,
// 🍂option type: String = 'roadmap'
// Google's map type. Valid values are 'roadmap', 'satellite' or 'terrain'. 'hybrid' is not really supported.
type: 'satellite',
maxNativeZoom: 21
},
initialize: function initialize(options) {
L.GridLayer.prototype.initialize.call(this, options);
var self = this;
if (options.asclientid) {
GoogleMapsLoader.CLIENT = options.googlekey;
} else {
GoogleMapsLoader.KEY = options.googlekey;
}
self._type = options.maptype || 'SATELLITE';
GoogleMapsLoader.load(function (_google) {
google = _google;
console.log('I just loaded google maps api');
self._ready = true;
//self._initMapObject();
// self.
self._initMutant();
self._update();
//this._ready = google.maps.Map !== undefined;
//if (!this._ready) L.Google.asyncWait.push(this);
});
// Couple data structures indexed by tile key
this._tileCallbacks = {}; // Callbacks for promises for tiles that are expected
this._freshTiles = {}; // Tiles from the mutant which haven't been requested yet
this._imagesPerTile = self._type === 'hybrid' ? 2 : 1;
this.createTile = self._type === 'hybrid' ? this._createMultiTile : this._createSingleTile;
},
onAdd: function onAdd(map) {
L.GridLayer.prototype.onAdd.call(this, map);
this._initMutantContainer();
// this._GAPIPromise.then(function () {
if (this._ready) {
this._map = map;
this._initMutant();
map.on('viewreset', this._reset, this);
map.on('move', this._update, this);
map.on('zoomend', this._handleZoomAnim, this);
map.on('resize', this._resize, this);
//20px instead of 1em to avoid a slight overlap with google's attribution
map._controlCorners.bottomright.style.marginBottom = '20px';
this._reset();
this._update();
}
//}.bind(this));
},
onRemove: function onRemove(map) {
L.GridLayer.prototype.onRemove.call(this, map);
map._container.removeChild(this._mutantContainer);
this._mutantContainer = undefined;
map.off('viewreset', this._reset, this);
map.off('move', this._update, this);
map.off('zoomend', this._handleZoomAnim, this);
map.off('resize', this._resize, this);
map._controlCorners.bottomright.style.marginBottom = '0em';
},
getAttribution: function getAttribution() {
return this.options.attribution;
},
setOpacity: function setOpacity(opacity) {
this.options.opacity = opacity;
if (opacity < 1) {
L.DomUtil.setOpacity(this._mutantContainer, opacity);
}
},
setElementSize: function setElementSize(e, size) {
e.style.width = size.x + 'px';
e.style.height = size.y + 'px';
},
_initMutantContainer: function _initMutantContainer() {
if (!this._mutantContainer) {
this._mutantContainer = L.DomUtil.create('div', 'leaflet-google-mutant leaflet-top leaflet-left');
this._mutantContainer.id = '_MutantContainer_' + L.Util.stamp(this._mutantContainer);
// this._mutantContainer.style.zIndex = 'auto';
this._mutantContainer.style.pointerEvents = 'none';
this._map.getContainer().appendChild(this._mutantContainer);
}
this.setOpacity(this.options.opacity);
this.setElementSize(this._mutantContainer, this._map.getSize());
this._attachObserver(this._mutantContainer);
},
_initMutant: function _initMutant() {
if (!this._ready || !this._mutantContainer) return;
this._mutantCenter = new google.maps.LatLng(0, 0);
var map = new google.maps.Map(this._mutantContainer, {
center: this._mutantCenter,
zoom: 0,
tilt: 0,
mapTypeId: google.maps.MapTypeId[this._type],
disableDefaultUI: true,
keyboardShortcuts: false,
draggable: false,
disableDoubleClickZoom: true,
scrollwheel: false,
streetViewControl: false,
styles: this.options.styles || {},
backgroundColor: 'transparent'
});
this._mutant = map;
// 🍂event spawned
// Fired when the mutant has been created.
this.fire('spawned', {
mapObject: map
});
},
_attachObserver: function _attachObserver(node) {
// console.log('Gonna observe', node);
var observer = new MutationObserver(this._onMutations.bind(this));
// pass in the target node, as well as the observer options
observer.observe(node, {
childList: true,
subtree: true
});
},
_onMutations: function _onMutations(mutations) {
for (var i = 0; i < mutations.length; ++i) {
var mutation = mutations[i];
for (var j = 0; j < mutation.addedNodes.length; ++j) {
var node = mutation.addedNodes[j];
if (node instanceof HTMLImageElement) {
this._onMutatedImage(node);
} else if (node instanceof HTMLElement) {
Array.prototype.forEach.call(node.querySelectorAll('img'), this._onMutatedImage.bind(this));
}
}
}
},
// Only images which 'src' attrib match this will be considered for moving around.
// Looks like some kind of string-based protobuf, maybe??
// Only the roads (and terrain, and vector-based stuff) match this pattern
_roadRegexp: /!1i(\d+)!2i(\d+)!3i(\d+)!/,
// On the other hand, raster imagery matches this other pattern
_satRegexp: /x=(\d+)&y=(\d+)&z=(\d+)/,
// On small viewports, when zooming in/out, a static image is requested
// This will not be moved around, just removed from the DOM.
_staticRegExp: /StaticMapService\.GetMapImage/,
_onMutatedImage: function _onMutatedImage(imgNode) {
// if (imgNode.src) {
// console.log('caught mutated image: ', imgNode.src);
// }
var coords;
var match = imgNode.src.match(this._roadRegexp);
var sublayer, parent;
if (match) {
coords = {
z: match[1],
x: match[2],
y: match[3]
};
if (this._imagesPerTile > 1) {
imgNode.style.zIndex = 1;
}
sublayer = 1;
} else {
match = imgNode.src.match(this._satRegexp);
if (match) {
coords = {
x: match[1],
y: match[2],
z: match[3]
};
}
// imgNode.style.zIndex = 0;
sublayer = 0;
}
if (coords) {
var key = this._tileCoordsToKey(coords);
imgNode.style.position = 'absolute';
if (this._imagesPerTile > 1) {
key += '/' + sublayer;
}
if (key in this._tileCallbacks && this._tileCallbacks[key]) {
// console.log('Fullfilling callback ', key);
this._tileCallbacks[key].pop()(imgNode);
if (!this._tileCallbacks[key].length) {
delete this._tileCallbacks[key];
}
} else {
// console.log('Caching for later', key);
parent = imgNode.parentNode;
if (parent) {
parent.removeChild(imgNode);
parent.removeChild = L.Util.falseFn;
// imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
}
if (key in this._freshTiles) {
this._freshTiles[key].push(imgNode);
} else {
this._freshTiles[key] = [imgNode];
}
}
} else if (imgNode.src.match(this._staticRegExp)) {
parent = imgNode.parentNode;
if (parent) {
// Remove the image, but don't store it anywhere.
// Image needs to be replaced instead of removed, as the container
// seems to be reused.
imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
}
}
},
// This will be used as this.createTile for 'roadmap', 'sat', 'terrain'
_createSingleTile: function createTile(coords, done) {
var key = this._tileCoordsToKey(coords);
// console.log('Need:', key);
if (key in this._freshTiles) {
var tile = this._freshTiles[key].pop();
if (!this._freshTiles[key].length) {
delete this._freshTiles[key];
}
L.Util.requestAnimFrame(done);
// console.log('Got ', key, ' from _freshTiles');
return tile;
} else {
var tileContainer = L.DomUtil.create('div');
this._tileCallbacks[key] = this._tileCallbacks[key] || [];
this._tileCallbacks[key].push(function (c /*, k*/) {
return function (imgNode) {
var parent = imgNode.parentNode;
if (parent) {
parent.removeChild(imgNode);
parent.removeChild = L.Util.falseFn;
// imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
}
c.appendChild(imgNode);
done();
// console.log('Sent ', k, ' to _tileCallbacks');
}.bind(this);
}.bind(this)(tileContainer /*, key*/));
return tileContainer;
}
},
// This will be used as this.createTile for 'hybrid'
_createMultiTile: function createTile(coords, done) {
var key = this._tileCoordsToKey(coords);
var tileContainer = L.DomUtil.create('div');
tileContainer.dataset.pending = this._imagesPerTile;
for (var i = 0; i < this._imagesPerTile; i++) {
var key2 = key + '/' + i;
if (key2 in this._freshTiles) {
tileContainer.appendChild(this._freshTiles[key2].pop());
if (!this._freshTiles[key2].length) {
delete this._freshTiles[key2];
}
tileContainer.dataset.pending--;
// console.log('Got ', key2, ' from _freshTiles');
} else {
this._tileCallbacks[key2] = this._tileCallbacks[key2] || [];
this._tileCallbacks[key2].push(function (c /*, k2*/) {
return function (imgNode) {
var parent = imgNode.parentNode;
if (parent) {
parent.removeChild(imgNode);
parent.removeChild = L.Util.falseFn;
// imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
}
c.appendChild(imgNode);
c.dataset.pending--;
if (!parseInt(c.dataset.pending)) {
done();
}
// console.log('Sent ', k2, ' to _tileCallbacks, still ', c.dataset.pending, ' images to go');
}.bind(this);
}.bind(this)(tileContainer /*, key2*/));
}
}
if (!parseInt(tileContainer.dataset.pending)) {
L.Util.requestAnimFrame(done);
}
return tileContainer;
},
_checkZoomLevels: function _checkZoomLevels() {
//setting the zoom level on the Google map may result in a different zoom level than the one requested
//(it won't go beyond the level for which they have data).
// verify and make sure the zoom levels on both Leaflet and Google maps are consistent
if (this._map.getZoom() !== undefined && this._mutant.getZoom() !== this._map.getZoom()) {
//zoom levels are out of sync. Set the leaflet zoom level to match the google one
this._map.setZoom(this._mutant.getZoom());
}
},
_reset: function _reset() {
this._initContainer();
},
_update: function _update() {
L.GridLayer.prototype._update.call(this);
if (!this._mutant) return;
var center = this._map.getCenter();
var _center = new google.maps.LatLng(center.lat, center.lng);
this._mutant.setCenter(_center);
var zoom = this._map.getZoom();
if (zoom !== undefined) {
this._mutant.setZoom(Math.round(this._map.getZoom()));
}
},
_resize: function _resize() {
var size = this._map.getSize();
if (this._mutantContainer.style.width === size.x && this._mutantContainer.style.height === size.y) return;
this.setElementSize(this._mutantContainer, size);
if (!this._mutant) return;
google.maps.event.trigger(this._mutant, 'resize');
},
_handleZoomAnim: function _handleZoomAnim() {
var center = this._map.getCenter();
var _center = new google.maps.LatLng(center.lat, center.lng);
this._mutant.setCenter(_center);
this._mutant.setZoom(Math.round(this._map.getZoom()));
},
// Agressively prune _freshtiles when a tile with the same key is removed,
// this prevents a problem where Leaflet keeps a loaded tile longer than
// GMaps, so that GMaps makes two requests but Leaflet only consumes one,
// polluting _freshTiles with stale data.
_removeTile: function _removeTile(key) {
if (this._imagesPerTile > 1) {
for (var i = 0; i < this._imagesPerTile; i++) {
var key2 = key + '/' + i;
if (key2 in this._freshTiles) {
delete this._freshTiles[key2];
}
// console.log('Pruned spurious hybrid _freshTiles');
}
} else {
if (key in this._freshTiles) {
delete this._freshTiles[key];
// console.log('Pruned spurious _freshTiles', key);
}
}
return L.GridLayer.prototype._removeTile.call(this, key);
}
});
// 🍂factory gridLayer.googleMutant(options)
// Returns a new `GridLayer.GoogleMutant` given its options
L.gridLayer.googleMutant = function (options) {
return new L.GridLayer.GoogleMutant(options);
};
+2 -2
View File
@@ -33,10 +33,10 @@
},
"homepage": "https://github.com/Charmatzis/react-leaflet-google#readme",
"peerDependencies": {
"leaflet": "^1.0.2",
"leaflet": "^1.0.3",
"react-leaflet": "^1.0.1",
"react": "^15.4.1",
"google-maps": "^3.2.1"
"google-maps":"^3.2.1"
},
"devDependencies": {
"babel-cli": "^6.8.0",
+2
View File
@@ -12,6 +12,8 @@ export default class GoogleLayer extends GridLayer {
componentWillMount() {
super.componentWillMount();
const {map: _map, googlekey, maptype, asclientid, ...props} = this.props;