@hpcc-js/map 2.77.12 → 2.77.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -20,8 +20,8 @@
20
20
  }
21
21
 
22
22
  var PKG_NAME = "@hpcc-js/map";
23
- var PKG_VERSION = "2.77.12";
24
- var BUILD_VERSION = "2.104.32";
23
+ var PKG_VERSION = "2.77.14";
24
+ var BUILD_VERSION = "2.104.37";
25
25
 
26
26
  /******************************************************************************
27
27
  Copyright (c) Microsoft Corporation.
@@ -6454,7 +6454,7 @@
6454
6454
  };
6455
6455
  GMap.prototype.createIcon = function (pinObj) {
6456
6456
  return {
6457
- path: "M 0,0 C -2,-20 -10,-22 -10,-30 A 10,10 0 1,1 10,-30 C 10,-22 2,-20 0,0 z M -2,-30",
6457
+ path: "M 0,0 C -2,-20 -10,-22 -10,-30 A 10,10 0 1,1 10,-30 C 10,-22 2,-20 0,0 z M -2,-30", // a 2,2 0 1,1 4,0 2,2 0 1,1",
6458
6458
  fillColor: pinObj.fillColor,
6459
6459
  fillOpacity: pinObj.fillOpacity || 0.8,
6460
6460
  scale: 0.5,
@@ -6475,7 +6475,7 @@
6475
6475
  circleObj.radius = circleObj.radius || 1;
6476
6476
  return new exports.google.maps.Circle({
6477
6477
  center: new exports.google.maps.LatLng(lat, lng),
6478
- radius: 16093 * circleObj.radius / 10,
6478
+ radius: 16093 * circleObj.radius / 10, // 16093 === 10 miles in metres
6479
6479
  fillColor: circleObj.fillColor || "red",
6480
6480
  strokeColor: circleObj.strokeColor || circleObj.fillColor || "black",
6481
6481
  strokeWeight: 0.5,
@@ -8877,447 +8877,449 @@ svg.leaflet-image-layer.leaflet-interactive path {
8877
8877
  /***/ }),
8878
8878
 
8879
8879
  /***/ 290:
8880
- /***/ (function(__unused_webpack_module, exports) {
8881
-
8882
- (function (global, factory) {
8883
- factory(exports) ;
8884
- }(this, (function (exports) {
8885
- // Based on https://github.com/shramov/leaflet-plugins
8886
- // GridLayer like https://avinmathew.com/leaflet-and-google-maps/ , but using MutationObserver instead of jQuery
8887
- // 🍂class GridLayer.GoogleMutant
8888
- // 🍂extends GridLayer
8889
-
8890
- var GoogleMutant = L.GridLayer.extend({
8891
- options: {
8892
- minZoom: 0,
8893
- maxZoom: 23,
8894
- tileSize: 256,
8895
- subdomains: 'abc',
8896
- errorTileUrl: '',
8897
- attribution: '', // The mutant container will add its own attribution anyways.
8898
- opacity: 1,
8899
- continuousWorld: false,
8900
- noWrap: false,
8901
- // 🍂option type: String = 'roadmap'
8902
- // Google's map type. Valid values are 'roadmap', 'satellite' or 'terrain'. 'hybrid' is not really supported.
8903
- type: 'roadmap',
8904
- maxNativeZoom: 21
8905
- },
8906
-
8907
- initialize: function (options) {
8908
- L.GridLayer.prototype.initialize.call(this, options);
8909
-
8910
- this._ready = !!window.google && !!window.google.maps && !!window.google.maps.Map;
8911
-
8912
- this._GAPIPromise = this._ready ? Promise.resolve(window.google) : new Promise(function (resolve, reject) {
8913
- var checkCounter = 0;
8914
- var intervalId = null;
8915
- intervalId = setInterval(function () {
8916
- if (checkCounter >= 10) {
8917
- clearInterval(intervalId);
8918
- return reject(new Error('window.google not found after 10 attempts'));
8919
- }
8920
- if (!!window.google && !!window.google.maps && !!window.google.maps.Map) {
8921
- clearInterval(intervalId);
8922
- return resolve(window.google);
8923
- }
8924
- checkCounter++;
8925
- }, 500);
8926
- });
8927
-
8928
- // Couple data structures indexed by tile key
8929
- this._tileCallbacks = {}; // Callbacks for promises for tiles that are expected
8930
- this._freshTiles = {}; // Tiles from the mutant which haven't been requested yet
8931
-
8932
- this._imagesPerTile = (this.options.type === 'hybrid') ? 2 : 1;
8933
- },
8880
+ /***/ (() => {
8934
8881
 
8935
- onAdd: function (map) {
8936
- L.GridLayer.prototype.onAdd.call(this, map);
8937
- this._initMutantContainer();
8882
+ // Based on https://github.com/shramov/leaflet-plugins
8883
+ // GridLayer like https://avinmathew.com/leaflet-and-google-maps/ , but using MutationObserver instead of jQuery
8884
+
8885
+
8886
+ // 🍂class GridLayer.GoogleMutant
8887
+ // 🍂extends GridLayer
8888
+ L.GridLayer.GoogleMutant = L.GridLayer.extend({
8889
+ options: {
8890
+ minZoom: 0,
8891
+ maxZoom: 23,
8892
+ tileSize: 256,
8893
+ subdomains: 'abc',
8894
+ errorTileUrl: '',
8895
+ attribution: '', // The mutant container will add its own attribution anyways.
8896
+ opacity: 1,
8897
+ continuousWorld: false,
8898
+ noWrap: false,
8899
+ // 🍂option type: String = 'roadmap'
8900
+ // Google's map type. Valid values are 'roadmap', 'satellite' or 'terrain'. 'hybrid' is not really supported.
8901
+ type: 'roadmap',
8902
+ maxNativeZoom: 21
8903
+ },
8904
+
8905
+ initialize: function (options) {
8906
+ L.GridLayer.prototype.initialize.call(this, options);
8907
+
8908
+ this._ready = !!window.google && !!window.google.maps && !!window.google.maps.Map;
8909
+
8910
+ this._GAPIPromise = this._ready ? Promise.resolve(window.google) : new Promise(function (resolve, reject) {
8911
+ var checkCounter = 0;
8912
+ var intervalId = null;
8913
+ intervalId = setInterval(function () {
8914
+ if (checkCounter >= 10) {
8915
+ clearInterval(intervalId);
8916
+ return reject(new Error('window.google not found after 10 attempts'));
8917
+ }
8918
+ if (!!window.google && !!window.google.maps && !!window.google.maps.Map) {
8919
+ clearInterval(intervalId);
8920
+ return resolve(window.google);
8921
+ }
8922
+ checkCounter++;
8923
+ }, 500);
8924
+ });
8938
8925
 
8939
- this._GAPIPromise.then(function () {
8940
- this._ready = true;
8941
- this._map = map;
8926
+ // Couple data structures indexed by tile key
8927
+ this._tileCallbacks = {}; // Callbacks for promises for tiles that are expected
8928
+ this._freshTiles = {}; // Tiles from the mutant which haven't been requested yet
8942
8929
 
8943
- this._initMutant();
8930
+ this._imagesPerTile = (this.options.type === 'hybrid') ? 2 : 1;
8931
+ },
8944
8932
 
8945
- map.on('viewreset', this._reset, this);
8946
- map.on('move', this._update, this);
8947
- map.on('zoomend', this._handleZoomAnim, this);
8948
- map.on('resize', this._resize, this);
8933
+ onAdd: function (map) {
8934
+ L.GridLayer.prototype.onAdd.call(this, map);
8935
+ this._initMutantContainer();
8949
8936
 
8950
- //handle layer being added to a map for which there are no Google tiles at the given zoom
8951
- google.maps.event.addListenerOnce(this._mutant, 'idle', function () {
8952
- this._checkZoomLevels();
8953
- this._mutantIsReady = true;
8954
- }.bind(this));
8937
+ this._GAPIPromise.then(function () {
8938
+ this._ready = true;
8939
+ this._map = map;
8955
8940
 
8956
- //20px instead of 1em to avoid a slight overlap with google's attribution
8957
- map._controlCorners.bottomright.style.marginBottom = '20px';
8958
- map._controlCorners.bottomleft.style.marginBottom = '20px';
8941
+ this._initMutant();
8959
8942
 
8960
- this._reset();
8961
- this._update();
8943
+ map.on('viewreset', this._reset, this);
8944
+ map.on('move', this._update, this);
8945
+ map.on('zoomend', this._handleZoomAnim, this);
8946
+ map.on('resize', this._resize, this);
8962
8947
 
8963
- if (this._subLayers) {
8964
- //restore previously added google layers
8965
- for (var layerName in this._subLayers) {
8966
- this._subLayers[layerName].setMap(this._mutant);
8967
- }
8968
- }
8948
+ //handle layer being added to a map for which there are no Google tiles at the given zoom
8949
+ google.maps.event.addListenerOnce(this._mutant, 'idle', function () {
8950
+ this._checkZoomLevels();
8951
+ this._mutantIsReady = true;
8969
8952
  }.bind(this));
8970
- },
8971
8953
 
8972
- onRemove: function (map) {
8973
- L.GridLayer.prototype.onRemove.call(this, map);
8974
- map._container.removeChild(this._mutantContainer);
8975
- this._mutantContainer = undefined;
8976
-
8977
- google.maps.event.clearListeners(map, 'idle');
8978
- google.maps.event.clearListeners(this._mutant, 'idle');
8979
- map.off('viewreset', this._reset, this);
8980
- map.off('move', this._update, this);
8981
- map.off('zoomend', this._handleZoomAnim, this);
8982
- map.off('resize', this._resize, this);
8983
-
8984
- if (map._controlCorners) {
8985
- map._controlCorners.bottomright.style.marginBottom = '0em';
8986
- map._controlCorners.bottomleft.style.marginBottom = '0em';
8987
- }
8988
- },
8954
+ //20px instead of 1em to avoid a slight overlap with google's attribution
8955
+ map._controlCorners.bottomright.style.marginBottom = '20px';
8956
+ map._controlCorners.bottomleft.style.marginBottom = '20px';
8989
8957
 
8990
- getAttribution: function () {
8991
- return this.options.attribution;
8992
- },
8958
+ this._reset();
8959
+ this._update();
8993
8960
 
8994
- setOpacity: function (opacity) {
8995
- this.options.opacity = opacity;
8996
- if (opacity < 1) {
8997
- L.DomUtil.setOpacity(this._mutantContainer, opacity);
8961
+ if (this._subLayers) {
8962
+ //restore previously added google layers
8963
+ for (var layerName in this._subLayers) {
8964
+ this._subLayers[layerName].setMap(this._mutant);
8965
+ }
8998
8966
  }
8999
- },
9000
-
9001
- setElementSize: function (e, size) {
9002
- e.style.width = size.x + 'px';
9003
- e.style.height = size.y + 'px';
9004
- },
9005
-
9006
-
9007
- addGoogleLayer: function (googleLayerName, options) {
9008
- if (!this._subLayers) this._subLayers = {};
9009
- return this._GAPIPromise.then(function () {
9010
- var Constructor = google.maps[googleLayerName];
9011
- var googleLayer = new Constructor(options);
9012
- googleLayer.setMap(this._mutant);
9013
- this._subLayers[googleLayerName] = googleLayer;
9014
- return googleLayer;
9015
- }.bind(this));
9016
- },
9017
-
9018
- removeGoogleLayer: function (googleLayerName) {
9019
- var googleLayer = this._subLayers && this._subLayers[googleLayerName];
9020
- if (!googleLayer) return;
9021
-
9022
- googleLayer.setMap(null);
9023
- delete this._subLayers[googleLayerName];
9024
- },
8967
+ }.bind(this));
8968
+ },
8969
+
8970
+ onRemove: function (map) {
8971
+ L.GridLayer.prototype.onRemove.call(this, map);
8972
+ map._container.removeChild(this._mutantContainer);
8973
+ this._mutantContainer = undefined;
8974
+
8975
+ google.maps.event.clearListeners(map, 'idle');
8976
+ google.maps.event.clearListeners(this._mutant, 'idle');
8977
+ map.off('viewreset', this._reset, this);
8978
+ map.off('move', this._update, this);
8979
+ map.off('zoomend', this._handleZoomAnim, this);
8980
+ map.off('resize', this._resize, this);
8981
+
8982
+ if (map._controlCorners) {
8983
+ map._controlCorners.bottomright.style.marginBottom = '0em';
8984
+ map._controlCorners.bottomleft.style.marginBottom = '0em';
8985
+ }
8986
+ },
9025
8987
 
8988
+ getAttribution: function () {
8989
+ return this.options.attribution;
8990
+ },
9026
8991
 
9027
- _initMutantContainer: function () {
9028
- if (!this._mutantContainer) {
9029
- this._mutantContainer = L.DomUtil.create('div', 'leaflet-google-mutant leaflet-top leaflet-left');
9030
- this._mutantContainer.id = '_MutantContainer_' + L.Util.stamp(this._mutantContainer);
9031
- this._mutantContainer.style.zIndex = '800'; //leaflet map pane at 400, controls at 1000
9032
- this._mutantContainer.style.pointerEvents = 'none';
8992
+ setOpacity: function (opacity) {
8993
+ this.options.opacity = opacity;
8994
+ if (opacity < 1) {
8995
+ L.DomUtil.setOpacity(this._mutantContainer, opacity);
8996
+ }
8997
+ },
8998
+
8999
+ setElementSize: function (e, size) {
9000
+ e.style.width = size.x + 'px';
9001
+ e.style.height = size.y + 'px';
9002
+ },
9003
+
9004
+
9005
+ addGoogleLayer: function (googleLayerName, options) {
9006
+ if (!this._subLayers) this._subLayers = {};
9007
+ return this._GAPIPromise.then(function () {
9008
+ var Constructor = google.maps[googleLayerName];
9009
+ var googleLayer = new Constructor(options);
9010
+ googleLayer.setMap(this._mutant);
9011
+ this._subLayers[googleLayerName] = googleLayer;
9012
+ return googleLayer;
9013
+ }.bind(this));
9014
+ },
9015
+
9016
+ removeGoogleLayer: function (googleLayerName) {
9017
+ var googleLayer = this._subLayers && this._subLayers[googleLayerName];
9018
+ if (!googleLayer) return;
9019
+
9020
+ googleLayer.setMap(null);
9021
+ delete this._subLayers[googleLayerName];
9022
+ },
9023
+
9024
+
9025
+ _initMutantContainer: function () {
9026
+ if (!this._mutantContainer) {
9027
+ this._mutantContainer = L.DomUtil.create('div', 'leaflet-google-mutant leaflet-top leaflet-left');
9028
+ this._mutantContainer.id = '_MutantContainer_' + L.Util.stamp(this._mutantContainer);
9029
+ this._mutantContainer.style.zIndex = '800'; //leaflet map pane at 400, controls at 1000
9030
+ this._mutantContainer.style.pointerEvents = 'none';
9031
+
9032
+ this._map.getContainer().appendChild(this._mutantContainer);
9033
+ }
9033
9034
 
9034
- this._map.getContainer().appendChild(this._mutantContainer);
9035
+ this.setOpacity(this.options.opacity);
9036
+ this.setElementSize(this._mutantContainer, this._map.getSize());
9037
+
9038
+ this._attachObserver(this._mutantContainer);
9039
+ },
9040
+
9041
+ _initMutant: function () {
9042
+ if (!this._ready || !this._mutantContainer) return;
9043
+ this._mutantCenter = new google.maps.LatLng(0, 0);
9044
+
9045
+ var map = new google.maps.Map(this._mutantContainer, {
9046
+ center: this._mutantCenter,
9047
+ zoom: 0,
9048
+ tilt: 0,
9049
+ mapTypeId: this.options.type,
9050
+ disableDefaultUI: true,
9051
+ keyboardShortcuts: false,
9052
+ draggable: false,
9053
+ disableDoubleClickZoom: true,
9054
+ scrollwheel: false,
9055
+ streetViewControl: false,
9056
+ styles: this.options.styles || {},
9057
+ backgroundColor: 'transparent'
9058
+ });
9059
+
9060
+ this._mutant = map;
9061
+
9062
+ google.maps.event.addListenerOnce(map, 'idle', function () {
9063
+ var nodes = this._mutantContainer.querySelectorAll('a');
9064
+ for (var i = 0; i < nodes.length; i++) {
9065
+ nodes[i].style.pointerEvents = 'auto';
9035
9066
  }
9067
+ }.bind(this));
9036
9068
 
9037
- this.setOpacity(this.options.opacity);
9038
- this.setElementSize(this._mutantContainer, this._map.getSize());
9039
-
9040
- this._attachObserver(this._mutantContainer);
9041
- },
9042
-
9043
- _initMutant: function () {
9044
- if (!this._ready || !this._mutantContainer) return;
9045
- this._mutantCenter = new google.maps.LatLng(0, 0);
9046
-
9047
- var map = new google.maps.Map(this._mutantContainer, {
9048
- center: this._mutantCenter,
9049
- zoom: 0,
9050
- tilt: 0,
9051
- mapTypeId: this.options.type,
9052
- disableDefaultUI: true,
9053
- keyboardShortcuts: false,
9054
- draggable: false,
9055
- disableDoubleClickZoom: true,
9056
- scrollwheel: false,
9057
- streetViewControl: false,
9058
- styles: this.options.styles || {},
9059
- backgroundColor: 'transparent'
9060
- });
9061
-
9062
- this._mutant = map;
9063
-
9064
- google.maps.event.addListenerOnce(map, 'idle', function () {
9065
- var nodes = this._mutantContainer.querySelectorAll('a');
9066
- for (var i = 0; i < nodes.length; i++) {
9067
- nodes[i].style.pointerEvents = 'auto';
9068
- }
9069
- }.bind(this));
9069
+ // 🍂event spawned
9070
+ // Fired when the mutant has been created.
9071
+ this.fire('spawned', {mapObject: map});
9072
+ },
9070
9073
 
9071
- // 🍂event spawned
9072
- // Fired when the mutant has been created.
9073
- this.fire('spawned', { mapObject: map });
9074
- },
9074
+ _attachObserver: function _attachObserver (node) {
9075
+ // console.log('Gonna observe', node);
9075
9076
 
9076
- _attachObserver: function _attachObserver(node) {
9077
- // console.log('Gonna observe', node);
9077
+ var observer = new MutationObserver(this._onMutations.bind(this));
9078
9078
 
9079
- var observer = new MutationObserver(this._onMutations.bind(this));
9079
+ // pass in the target node, as well as the observer options
9080
+ observer.observe(node, { childList: true, subtree: true });
9081
+ },
9080
9082
 
9081
- // pass in the target node, as well as the observer options
9082
- observer.observe(node, { childList: true, subtree: true });
9083
- },
9083
+ _onMutations: function _onMutations (mutations) {
9084
+ for (var i = 0; i < mutations.length; ++i) {
9085
+ var mutation = mutations[i];
9086
+ for (var j = 0; j < mutation.addedNodes.length; ++j) {
9087
+ var node = mutation.addedNodes[j];
9084
9088
 
9085
- _onMutations: function _onMutations(mutations) {
9086
- for (var i = 0; i < mutations.length; ++i) {
9087
- var mutation = mutations[i];
9088
- for (var j = 0; j < mutation.addedNodes.length; ++j) {
9089
- var node = mutation.addedNodes[j];
9090
-
9091
- if (node instanceof HTMLImageElement) {
9092
- this._onMutatedImage(node);
9093
- } else if (node instanceof HTMLElement) {
9094
- Array.prototype.forEach.call(node.querySelectorAll('img'), this._onMutatedImage.bind(this));
9095
- }
9089
+ if (node instanceof HTMLImageElement) {
9090
+ this._onMutatedImage(node);
9091
+ } else if (node instanceof HTMLElement) {
9092
+ Array.prototype.forEach.call(node.querySelectorAll('img'), this._onMutatedImage.bind(this));
9096
9093
  }
9097
9094
  }
9098
- },
9099
-
9100
- // Only images which 'src' attrib match this will be considered for moving around.
9101
- // Looks like some kind of string-based protobuf, maybe??
9102
- // Only the roads (and terrain, and vector-based stuff) match this pattern
9103
- _roadRegexp: /!1i(\d+)!2i(\d+)!3i(\d+)!/,
9104
-
9105
- // On the other hand, raster imagery matches this other pattern
9106
- _satRegexp: /x=(\d+)&y=(\d+)&z=(\d+)/,
9107
-
9108
- // On small viewports, when zooming in/out, a static image is requested
9109
- // This will not be moved around, just removed from the DOM.
9110
- _staticRegExp: /StaticMapService\.GetMapImage/,
9111
-
9112
- _onMutatedImage: function _onMutatedImage(imgNode) {
9113
- // if (imgNode.src) {
9114
- // console.log('caught mutated image: ', imgNode.src);
9115
- // }
9116
-
9117
- var coords;
9118
- var match = imgNode.src.match(this._roadRegexp);
9119
- var sublayer = 0;
9120
-
9095
+ }
9096
+ },
9097
+
9098
+ // Only images which 'src' attrib match this will be considered for moving around.
9099
+ // Looks like some kind of string-based protobuf, maybe??
9100
+ // Only the roads (and terrain, and vector-based stuff) match this pattern
9101
+ _roadRegexp: /!1i(\d+)!2i(\d+)!3i(\d+)!/,
9102
+
9103
+ // On the other hand, raster imagery matches this other pattern
9104
+ _satRegexp: /x=(\d+)&y=(\d+)&z=(\d+)/,
9105
+
9106
+ // On small viewports, when zooming in/out, a static image is requested
9107
+ // This will not be moved around, just removed from the DOM.
9108
+ _staticRegExp: /StaticMapService\.GetMapImage/,
9109
+
9110
+ _onMutatedImage: function _onMutatedImage (imgNode) {
9111
+ // if (imgNode.src) {
9112
+ // console.log('caught mutated image: ', imgNode.src);
9113
+ // }
9114
+
9115
+ var coords;
9116
+ var match = imgNode.src.match(this._roadRegexp);
9117
+ var sublayer = 0;
9118
+
9119
+ if (match) {
9120
+ coords = {
9121
+ z: match[1],
9122
+ x: match[2],
9123
+ y: match[3]
9124
+ };
9125
+ if (this._imagesPerTile > 1) {
9126
+ imgNode.style.zIndex = 1;
9127
+ sublayer = 1;
9128
+ }
9129
+ } else {
9130
+ match = imgNode.src.match(this._satRegexp);
9121
9131
  if (match) {
9122
9132
  coords = {
9123
- z: match[1],
9124
- x: match[2],
9125
- y: match[3]
9133
+ x: match[1],
9134
+ y: match[2],
9135
+ z: match[3]
9126
9136
  };
9127
- if (this._imagesPerTile > 1) {
9128
- imgNode.style.zIndex = 1;
9129
- sublayer = 1;
9130
- }
9131
- } else {
9132
- match = imgNode.src.match(this._satRegexp);
9133
- if (match) {
9134
- coords = {
9135
- x: match[1],
9136
- y: match[2],
9137
- z: match[3]
9138
- };
9139
- }
9140
- // imgNode.style.zIndex = 0;
9141
- sublayer = 0;
9142
9137
  }
9138
+ // imgNode.style.zIndex = 0;
9139
+ sublayer = 0;
9140
+ }
9143
9141
 
9144
- if (coords) {
9145
- var tileKey = this._tileCoordsToKey(coords);
9146
- imgNode.style.position = 'absolute';
9147
- imgNode.style.visibility = 'hidden';
9148
-
9149
- var key = tileKey + '/' + sublayer;
9150
- // console.log('mutation for tile', key)
9151
- //store img so it can also be used in subsequent tile requests
9152
- this._freshTiles[key] = imgNode;
9153
-
9154
- if (key in this._tileCallbacks && this._tileCallbacks[key]) {
9155
- // console.log('Fullfilling callback ', key);
9156
- //fullfill most recent tileCallback because there maybe callbacks that will never get a
9157
- //corresponding mutation (because map moved to quickly...)
9158
- this._tileCallbacks[key].pop()(imgNode);
9159
- if (!this._tileCallbacks[key].length) { delete this._tileCallbacks[key]; }
9160
- } else {
9161
- if (this._tiles[tileKey]) {
9162
- //we already have a tile in this position (mutation is probably a google layer being added)
9163
- //replace it
9164
- var c = this._tiles[tileKey].el;
9165
- var oldImg = (sublayer === 0) ? c.firstChild : c.firstChild.nextSibling;
9166
- var cloneImgNode = this._clone(imgNode);
9167
- c.replaceChild(cloneImgNode, oldImg);
9168
- }
9169
- }
9170
- } else if (imgNode.src.match(this._staticRegExp)) {
9171
- imgNode.style.visibility = 'hidden';
9172
- }
9173
- },
9174
-
9175
-
9176
- createTile: function (coords, done) {
9177
- var key = this._tileCoordsToKey(coords);
9178
-
9179
- var tileContainer = L.DomUtil.create('div');
9180
- tileContainer.dataset.pending = this._imagesPerTile;
9181
- done = done.bind(this, null, tileContainer);
9182
-
9183
- for (var i = 0; i < this._imagesPerTile; i++) {
9184
- var key2 = key + '/' + i;
9185
- if (key2 in this._freshTiles) {
9186
- var imgNode = this._freshTiles[key2];
9187
- tileContainer.appendChild(this._clone(imgNode));
9188
- tileContainer.dataset.pending--;
9189
- // console.log('Got ', key2, ' from _freshTiles');
9190
- } else {
9191
- this._tileCallbacks[key2] = this._tileCallbacks[key2] || [];
9192
- this._tileCallbacks[key2].push((function (c/*, k2*/) {
9193
- return function (imgNode) {
9194
- c.appendChild(this._clone(imgNode));
9195
- c.dataset.pending--;
9196
- if (!parseInt(c.dataset.pending)) { done(); }
9197
- // console.log('Sent ', k2, ' to _tileCallbacks, still ', c.dataset.pending, ' images to go');
9198
- }.bind(this);
9199
- }.bind(this))(tileContainer/*, key2*/));
9142
+ if (coords) {
9143
+ var tileKey = this._tileCoordsToKey(coords);
9144
+ imgNode.style.position = 'absolute';
9145
+ imgNode.style.visibility = 'hidden';
9146
+
9147
+ var key = tileKey + '/' + sublayer;
9148
+ // console.log('mutation for tile', key)
9149
+ //store img so it can also be used in subsequent tile requests
9150
+ this._freshTiles[key] = imgNode;
9151
+
9152
+ if (key in this._tileCallbacks && this._tileCallbacks[key]) {
9153
+ // console.log('Fullfilling callback ', key);
9154
+ //fullfill most recent tileCallback because there maybe callbacks that will never get a
9155
+ //corresponding mutation (because map moved to quickly...)
9156
+ this._tileCallbacks[key].pop()(imgNode);
9157
+ if (!this._tileCallbacks[key].length) { delete this._tileCallbacks[key]; }
9158
+ } else {
9159
+ if (this._tiles[tileKey]) {
9160
+ //we already have a tile in this position (mutation is probably a google layer being added)
9161
+ //replace it
9162
+ var c = this._tiles[tileKey].el;
9163
+ var oldImg = (sublayer === 0) ? c.firstChild : c.firstChild.nextSibling;
9164
+ var cloneImgNode = this._clone(imgNode);
9165
+ c.replaceChild(cloneImgNode, oldImg);
9200
9166
  }
9201
9167
  }
9168
+ } else if (imgNode.src.match(this._staticRegExp)) {
9169
+ imgNode.style.visibility = 'hidden';
9170
+ }
9171
+ },
9202
9172
 
9203
- if (!parseInt(tileContainer.dataset.pending)) {
9204
- L.Util.requestAnimFrame(done);
9205
- }
9206
- return tileContainer;
9207
- },
9208
-
9209
- _clone: function (imgNode) {
9210
- var clonedImgNode = imgNode.cloneNode(true);
9211
- clonedImgNode.style.visibility = 'visible';
9212
- return clonedImgNode;
9213
- },
9214
9173
 
9215
- _checkZoomLevels: function () {
9216
- //setting the zoom level on the Google map may result in a different zoom level than the one requested
9217
- //(it won't go beyond the level for which they have data).
9218
- var zoomLevel = this._map.getZoom();
9219
- var gMapZoomLevel = this._mutant.getZoom();
9220
- if (!zoomLevel || !gMapZoomLevel) return;
9174
+ createTile: function (coords, done) {
9175
+ var key = this._tileCoordsToKey(coords);
9221
9176
 
9177
+ var tileContainer = L.DomUtil.create('div');
9178
+ tileContainer.dataset.pending = this._imagesPerTile;
9179
+ done = done.bind(this, null, tileContainer);
9222
9180
 
9223
- if ((gMapZoomLevel !== zoomLevel) || //zoom levels are out of sync, Google doesn't have data
9224
- (gMapZoomLevel > this.options.maxNativeZoom)) { //at current location, Google does have data (contrary to maxNativeZoom)
9225
- //Update maxNativeZoom
9226
- this._setMaxNativeZoom(gMapZoomLevel);
9227
- }
9228
- },
9229
-
9230
- _setMaxNativeZoom: function (zoomLevel) {
9231
- if (zoomLevel != this.options.maxNativeZoom) {
9232
- this.options.maxNativeZoom = zoomLevel;
9233
- this._resetView();
9181
+ for (var i = 0; i < this._imagesPerTile; i++) {
9182
+ var key2 = key + '/' + i;
9183
+ if (key2 in this._freshTiles) {
9184
+ var imgNode = this._freshTiles[key2];
9185
+ tileContainer.appendChild(this._clone(imgNode));
9186
+ tileContainer.dataset.pending--;
9187
+ // console.log('Got ', key2, ' from _freshTiles');
9188
+ } else {
9189
+ this._tileCallbacks[key2] = this._tileCallbacks[key2] || [];
9190
+ this._tileCallbacks[key2].push( (function (c/*, k2*/) {
9191
+ return function (imgNode) {
9192
+ c.appendChild(this._clone(imgNode));
9193
+ c.dataset.pending--;
9194
+ if (!parseInt(c.dataset.pending)) { done(); }
9195
+ // console.log('Sent ', k2, ' to _tileCallbacks, still ', c.dataset.pending, ' images to go');
9196
+ }.bind(this);
9197
+ }.bind(this))(tileContainer/*, key2*/) );
9234
9198
  }
9235
- },
9236
-
9237
- _reset: function () {
9238
- this._initContainer();
9239
- },
9240
-
9241
- _update: function () {
9242
- // zoom level check needs to happen before super's implementation (tile addition/creation)
9243
- // otherwise tiles may be missed if maxNativeZoom is not yet correctly determined
9244
- if (this._mutant) {
9245
- var center = this._map.getCenter();
9246
- var _center = new google.maps.LatLng(center.lat, center.lng);
9247
-
9248
- this._mutant.setCenter(_center);
9249
- var zoom = this._map.getZoom();
9250
- var fractionalLevel = zoom !== Math.round(zoom);
9251
- var mutantZoom = this._mutant.getZoom();
9252
-
9253
- //ignore fractional zoom levels
9254
- if (!fractionalLevel && (zoom != mutantZoom)) {
9255
- this._mutant.setZoom(zoom);
9199
+ }
9256
9200
 
9257
- if (this._mutantIsReady) this._checkZoomLevels();
9258
- //else zoom level check will be done later by 'idle' handler
9259
- }
9260
- }
9201
+ if (!parseInt(tileContainer.dataset.pending)) {
9202
+ L.Util.requestAnimFrame(done);
9203
+ }
9204
+ return tileContainer;
9205
+ },
9206
+
9207
+ _clone: function (imgNode) {
9208
+ var clonedImgNode = imgNode.cloneNode(true);
9209
+ clonedImgNode.style.visibility = 'visible';
9210
+ return clonedImgNode;
9211
+ },
9212
+
9213
+ _checkZoomLevels: function () {
9214
+ //setting the zoom level on the Google map may result in a different zoom level than the one requested
9215
+ //(it won't go beyond the level for which they have data).
9216
+ var zoomLevel = this._map.getZoom();
9217
+ var gMapZoomLevel = this._mutant.getZoom();
9218
+ if (!zoomLevel || !gMapZoomLevel) return;
9219
+
9220
+
9221
+ if ((gMapZoomLevel !== zoomLevel) || //zoom levels are out of sync, Google doesn't have data
9222
+ (gMapZoomLevel > this.options.maxNativeZoom)) { //at current location, Google does have data (contrary to maxNativeZoom)
9223
+ //Update maxNativeZoom
9224
+ this._setMaxNativeZoom(gMapZoomLevel);
9225
+ }
9226
+ },
9261
9227
 
9262
- L.GridLayer.prototype._update.call(this);
9263
- },
9228
+ _setMaxNativeZoom: function (zoomLevel) {
9229
+ if (zoomLevel != this.options.maxNativeZoom) {
9230
+ this.options.maxNativeZoom = zoomLevel;
9231
+ this._resetView();
9232
+ }
9233
+ },
9264
9234
 
9265
- _resize: function () {
9266
- var size = this._map.getSize();
9267
- if (this._mutantContainer.style.width === size.x &&
9268
- this._mutantContainer.style.height === size.y)
9269
- return;
9270
- this.setElementSize(this._mutantContainer, size);
9271
- if (!this._mutant) return;
9272
- google.maps.event.trigger(this._mutant, 'resize');
9273
- },
9235
+ _reset: function () {
9236
+ this._initContainer();
9237
+ },
9274
9238
 
9275
- _handleZoomAnim: function () {
9276
- if (!this._mutant) return;
9239
+ _update: function () {
9240
+ // zoom level check needs to happen before super's implementation (tile addition/creation)
9241
+ // otherwise tiles may be missed if maxNativeZoom is not yet correctly determined
9242
+ if (this._mutant) {
9277
9243
  var center = this._map.getCenter();
9278
9244
  var _center = new google.maps.LatLng(center.lat, center.lng);
9279
9245
 
9280
9246
  this._mutant.setCenter(_center);
9281
- this._mutant.setZoom(Math.round(this._map.getZoom()));
9282
- },
9283
-
9284
- // Agressively prune _freshtiles when a tile with the same key is removed,
9285
- // this prevents a problem where Leaflet keeps a loaded tile longer than
9286
- // GMaps, so that GMaps makes two requests but Leaflet only consumes one,
9287
- // polluting _freshTiles with stale data.
9288
- _removeTile: function (key) {
9289
- if (!this._mutant) return;
9290
-
9291
- //give time for animations to finish before checking it tile should be pruned
9292
- setTimeout(this._pruneTile.bind(this, key), 1000);
9293
-
9247
+ var zoom = this._map.getZoom();
9248
+ var fractionalLevel = zoom !== Math.round(zoom);
9249
+ var mutantZoom = this._mutant.getZoom();
9250
+
9251
+ //ignore fractional zoom levels
9252
+ if (!fractionalLevel && (zoom != mutantZoom)) {
9253
+ this._mutant.setZoom(zoom);
9254
+
9255
+ if (this._mutantIsReady) this._checkZoomLevels();
9256
+ //else zoom level check will be done later by 'idle' handler
9257
+ }
9258
+ }
9294
9259
 
9295
- return L.GridLayer.prototype._removeTile.call(this, key);
9296
- },
9260
+ L.GridLayer.prototype._update.call(this);
9261
+ },
9297
9262
 
9298
- _pruneTile: function (key) {
9299
- var gZoom = this._mutant.getZoom();
9300
- var tileZoom = key.split(':')[2];
9301
- var googleBounds = this._mutant.getBounds();
9302
- var sw = googleBounds.getSouthWest();
9303
- var ne = googleBounds.getNorthEast();
9304
- var gMapBounds = L.latLngBounds([[sw.lat(), sw.lng()], [ne.lat(), ne.lng()]]);
9305
-
9306
- for (var i = 0; i < this._imagesPerTile; i++) {
9307
- var key2 = key + '/' + i;
9308
- if (key2 in this._freshTiles) {
9309
- var tileBounds = this._map && this._keyToBounds(key);
9310
- var stillVisible = this._map && tileBounds.overlaps(gMapBounds) && (tileZoom == gZoom);
9311
-
9312
- if (!stillVisible) delete this._freshTiles[key2];
9313
- // console.log('Prunning of ', key, (!stillVisible))
9314
- }
9263
+ _resize: function () {
9264
+ var size = this._map.getSize();
9265
+ if (this._mutantContainer.style.width === size.x &&
9266
+ this._mutantContainer.style.height === size.y)
9267
+ return;
9268
+ this.setElementSize(this._mutantContainer, size);
9269
+ if (!this._mutant) return;
9270
+ google.maps.event.trigger(this._mutant, 'resize');
9271
+ },
9272
+
9273
+ _handleZoomAnim: function () {
9274
+ if (!this._mutant) return;
9275
+ var center = this._map.getCenter();
9276
+ var _center = new google.maps.LatLng(center.lat, center.lng);
9277
+
9278
+ this._mutant.setCenter(_center);
9279
+ this._mutant.setZoom(Math.round(this._map.getZoom()));
9280
+ },
9281
+
9282
+ // Agressively prune _freshtiles when a tile with the same key is removed,
9283
+ // this prevents a problem where Leaflet keeps a loaded tile longer than
9284
+ // GMaps, so that GMaps makes two requests but Leaflet only consumes one,
9285
+ // polluting _freshTiles with stale data.
9286
+ _removeTile: function (key) {
9287
+ if (!this._mutant) return;
9288
+
9289
+ //give time for animations to finish before checking it tile should be pruned
9290
+ setTimeout(this._pruneTile.bind(this, key), 1000);
9291
+
9292
+
9293
+ return L.GridLayer.prototype._removeTile.call(this, key);
9294
+ },
9295
+
9296
+ _pruneTile: function (key) {
9297
+ var gZoom = this._mutant.getZoom();
9298
+ var tileZoom = key.split(':')[2];
9299
+ var googleBounds = this._mutant.getBounds();
9300
+ var sw = googleBounds.getSouthWest();
9301
+ var ne = googleBounds.getNorthEast();
9302
+ var gMapBounds = L.latLngBounds([[sw.lat(), sw.lng()], [ne.lat(), ne.lng()]]);
9303
+
9304
+ for (var i=0; i<this._imagesPerTile; i++) {
9305
+ var key2 = key + '/' + i;
9306
+ if (key2 in this._freshTiles) {
9307
+ var tileBounds = this._map && this._keyToBounds(key);
9308
+ var stillVisible = this._map && tileBounds.overlaps(gMapBounds) && (tileZoom == gZoom);
9309
+
9310
+ if (!stillVisible) delete this._freshTiles[key2];
9311
+ // console.log('Prunning of ', key, (!stillVisible))
9315
9312
  }
9316
9313
  }
9317
- });
9314
+ }
9315
+ });
9316
+
9318
9317
 
9319
- exports.GoogleMutant = GoogleMutant;
9320
- })));
9318
+ // 🍂factory gridLayer.googleMutant(options)
9319
+ // Returns a new `GridLayer.GoogleMutant` given its options
9320
+ L.gridLayer.googleMutant = function (options) {
9321
+ return new L.GridLayer.GoogleMutant(options);
9322
+ };
9321
9323
 
9322
9324
 
9323
9325
  /***/ }),