kmz_compressor 2.1.3 → 2.1.4
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.
@@ -17,7 +17,7 @@ window.MapLayerManager = function(map){
|
|
17
17
|
var retryDelay = retryDelay || 2000;
|
18
18
|
|
19
19
|
kmlURL = sanitizeURI(kmlURL);
|
20
|
-
options = jQuery.extend(true, {zIndex:
|
20
|
+
options = jQuery.extend(true, {zIndex:getDrawOrder(layerName)}, options); // Deep copy the options in case they are changed between now and when the map is ready to load
|
21
21
|
|
22
22
|
return $.ajax(kmlURL, {type:'head', statusCode:{
|
23
23
|
202: function(){ setTimeout(function(){ cacheAndLoadKMLLayer(kmlURL, layerName, options, retryDelay * 2) }, retryDelay) },
|
@@ -36,7 +36,7 @@ window.MapLayerManager = function(map){
|
|
36
36
|
function loadKMLLayer(kmlURL, layerName, options) {
|
37
37
|
// Replace spaces with pluses so we don't have problems with some things turning them into %20s and some not
|
38
38
|
kmlURL = sanitizeURI(kmlURL);
|
39
|
-
options = jQuery.extend(true, {zIndex:
|
39
|
+
options = jQuery.extend(true, {zIndex:getDrawOrder(layerName), map:map}, options);
|
40
40
|
|
41
41
|
var kmlLayer = new google.maps.KmlLayer(kmlURL, options);
|
42
42
|
var layer = addLayer(layerName, kmlLayer)
|
@@ -145,6 +145,17 @@ window.MapLayerManager = function(map){
|
|
145
145
|
}
|
146
146
|
}
|
147
147
|
|
148
|
+
// Returns the draw order for the layer if it exists,
|
149
|
+
// Else generates and returns a new draw order
|
150
|
+
function getDrawOrder(layerName){
|
151
|
+
var layer = getLayer(layerName)
|
152
|
+
if (layer){
|
153
|
+
return layer.kml.getZIndex()
|
154
|
+
} else {
|
155
|
+
return zIndexCount++
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
148
159
|
function setKMLOptions(layerName, options){
|
149
160
|
var layer = getLayer(layerName)
|
150
161
|
if (layer){
|
@@ -218,6 +229,8 @@ window.MapLayerManager = function(map){
|
|
218
229
|
// Keep layers synced with their state
|
219
230
|
function sweep(){
|
220
231
|
var foundLayers = [];
|
232
|
+
var staleLayers = []
|
233
|
+
|
221
234
|
eachLayer(function(layer, index){
|
222
235
|
var kmlStatus = layer.kml ? layer.kml.getStatus() : null;
|
223
236
|
|
@@ -235,15 +248,25 @@ window.MapLayerManager = function(map){
|
|
235
248
|
}
|
236
249
|
|
237
250
|
// Remove old layers
|
238
|
-
// Sweep through layers from the newest to oldest, if a layer name is seen more than once,
|
251
|
+
// Sweep through layers from the newest to oldest, if a layer name is seen more than once, mark all but the newest for deletion
|
239
252
|
// Don't delete an instance if we haven't yet seen a version of it with status 'OK'
|
240
253
|
if ($.inArray(layer.name, foundLayers) > -1){
|
241
|
-
|
242
|
-
layers.splice(index, 1);
|
254
|
+
staleLayers.push(layer)
|
243
255
|
} else if (layer.loaded) {
|
244
256
|
foundLayers.push(layer.name)
|
245
257
|
}
|
246
258
|
})
|
259
|
+
|
260
|
+
// Delete stale layers
|
261
|
+
$.each(staleLayers, function(_, staleLayer){
|
262
|
+
eachLayer(function(layer, index){
|
263
|
+
if (layer == staleLayer){
|
264
|
+
layer.kml.setMap(null);
|
265
|
+
layers.splice(index, 1)
|
266
|
+
return false
|
267
|
+
}
|
268
|
+
})
|
269
|
+
})
|
247
270
|
}
|
248
271
|
|
249
272
|
// Replace spaces with pluses so we don't have problems with some things turning them into %20s and some not
|
@@ -339,6 +362,7 @@ window.MapLayerManager = function(map){
|
|
339
362
|
this.hideLayer = hideLayer,
|
340
363
|
this.showLayer = showLayer,
|
341
364
|
this.setDrawOrder = setDrawOrder,
|
365
|
+
this.getDrawOrder = getDrawOrder,
|
342
366
|
this.eachLayer = eachLayer,
|
343
367
|
this.setKMLOptions = setKMLOptions
|
344
368
|
}
|