kmz_compressor 2.1.1 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  window.MapLayerManager = function(map){
2
+ var manager = this
2
3
  var map = map;
3
4
  var layers = []
4
5
  var loadingCount = 0 // How many layers are being loaded
@@ -40,7 +41,7 @@ window.MapLayerManager = function(map){
40
41
  var kmlLayer = new google.maps.KmlLayer(kmlURL, options);
41
42
  var layer = addLayer(layerName, kmlLayer)
42
43
  loadingCount++
43
- $(map.getDiv()).trigger({type: layerLoadingEventName, layer:layer})
44
+ triggerEvent(layerLoadingEventName, layer)
44
45
 
45
46
  // Try and catch the defaultviewport_changed event so we can remove the old layer (sometimes this works, sometimes not)
46
47
  google.maps.event.addListener(kmlLayer, 'defaultviewport_changed', function(){
@@ -52,7 +53,7 @@ window.MapLayerManager = function(map){
52
53
  closeInfowindowsExcept(layerName)
53
54
 
54
55
  // Create a bubbling event when a layer is clicked
55
- $(map.getDiv()).trigger({type: layerClickedEventName, layer:layer, kmlEvent:kmlEvent})
56
+ triggerEvent(layerClickedEventName, layer, {kmlEvent:kmlEvent})
56
57
  });
57
58
  }
58
59
 
@@ -109,7 +110,7 @@ window.MapLayerManager = function(map){
109
110
  var layer = getLayer(layerName);
110
111
 
111
112
  if (layer){
112
- $(map.getDiv()).trigger({type: layerHiddenEventName, layer:layer})
113
+ triggerEvent(layerHiddenEventName, layer)
113
114
  }
114
115
 
115
116
  if (layer && layer.kml && !layer.oldMap){
@@ -195,7 +196,7 @@ window.MapLayerManager = function(map){
195
196
  if (layer.name == layerName){
196
197
  layer.kml.setMap(null)
197
198
  layers.splice(index, 1);
198
- $(map.getDiv()).trigger({type: layerRemovedEventName, layer:layer})
199
+ triggerEvent(layerRemovedEventName, layer)
199
200
  return;
200
201
  }
201
202
  });
@@ -225,7 +226,7 @@ window.MapLayerManager = function(map){
225
226
  loadingCount--
226
227
  layer.loaded = true
227
228
  layer.error = kmlStatus == 'OK' ? null : kmlStatus // if there were any errors, record them
228
- $(map.getDiv()).trigger({type: layerLoadedEventName, layer:layer})
229
+ triggerEvent(layerLoadedEventName, layer)
229
230
  }
230
231
 
231
232
  // A layer should be hidden, but the kml is showing, hide it (i.e. correct layers that were hidden before the kml was loaded)
@@ -306,6 +307,16 @@ window.MapLayerManager = function(map){
306
307
  return $('<a>').attr('href', url)[0]
307
308
  }
308
309
 
310
+ // Triggers an event on the map and the MapLayerManager itself
311
+ // Triggers two events, one with the eventName, and one with the eventName:layer.name
312
+ // e.g. "map:layerLoaded" and "map:layerLoaded:PoliceCoverage"
313
+ function triggerEvent(eventName, layer, additionalData){
314
+ var data = $.extend({type:eventName, layer:layer}, additionalData)
315
+ var nameData = $.extend({type:eventName + ':' + layer.name, layer:layer}, additionalData)
316
+ $(map.getDiv()).trigger(data).trigger(nameData)
317
+ $(manager).trigger(data).trigger(nameData)
318
+ }
319
+
309
320
  // INIT
310
321
 
311
322
  // Because google events sometimes get missed, we ensure we're up to date every now and again
@@ -314,21 +325,20 @@ window.MapLayerManager = function(map){
314
325
 
315
326
  // PUBLIC INTERFACE
316
327
 
317
- return {
318
- cacheAndLoadKMLLayer : cacheAndLoadKMLLayer,
319
- loadKMLLayer : loadKMLLayer,
320
- centerWhenLoaded : centerWhenLoaded,
321
- addLayer : addLayer,
322
- removeLayer : removeLayer,
323
- layerNames : layerNames,
324
- map : map,
325
- loadingCount : loadingCount,
326
- closeInfowindows : closeInfowindows,
327
- closeInfowindowsExcept : closeInfowindowsExcept,
328
- hideLayer : hideLayer,
329
- showLayer : showLayer,
330
- setDrawOrder : setDrawOrder,
331
- eachLayer : eachLayer,
332
- setKMLOptions : setKMLOptions
333
- }
328
+ this.cacheAndLoadKMLLayer = cacheAndLoadKMLLayer,
329
+ this.loadKMLLayer = loadKMLLayer,
330
+ this.centerWhenLoaded = centerWhenLoaded,
331
+ this.centerOnLayers = centerOnLayers,
332
+ this.addLayer = addLayer,
333
+ this.removeLayer = removeLayer,
334
+ this.layerNames = layerNames,
335
+ this.map = map,
336
+ this.loadingCount = loadingCount,
337
+ this.closeInfowindows = closeInfowindows,
338
+ this.closeInfowindowsExcept = closeInfowindowsExcept,
339
+ this.hideLayer = hideLayer,
340
+ this.showLayer = showLayer,
341
+ this.setDrawOrder = setDrawOrder,
342
+ this.eachLayer = eachLayer,
343
+ this.setKMLOptions = setKMLOptions
334
344
  }
@@ -1,3 +1,3 @@
1
1
  module KMZCompressor
2
- VERSION = "2.1.1"
2
+ VERSION = "2.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kmz_compressor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-14 00:00:00.000000000 Z
13
+ date: 2015-04-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails