gmaps4rails 0.7.3 → 0.7.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.
- data/public/javascripts/gmaps4rails.js +36 -21
- metadata +3 -3
@@ -33,8 +33,7 @@ var Gmaps4Rails = {
|
|
33
33
|
},
|
34
34
|
|
35
35
|
//Stored variables
|
36
|
-
|
37
|
-
markers : [], //contains raw markers
|
36
|
+
markers : [], //contains all markers, each marker contain a google Marker object in google_object
|
38
37
|
bounds: null, //contains current bounds
|
39
38
|
polygons: null, //contains raw data, array of arrays (first element cold be a hash containing options)
|
40
39
|
polygon_objects: [], //contains processed google.maps.Polygon
|
@@ -310,36 +309,47 @@ var Gmaps4Rails = {
|
|
310
309
|
|
311
310
|
// clear markers
|
312
311
|
clear_markers: function(){
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
312
|
+
if (this.markerClusterer != null){
|
313
|
+
this.markerClusterer.clearMarkers();
|
314
|
+
}
|
315
|
+
for (var i = 0; i < this.markers.length; ++i) {
|
316
|
+
this.markers[i].google_object.setMap(null);
|
317
|
+
}
|
317
318
|
},
|
318
319
|
|
319
320
|
// replace old markers with new markers on an existing map
|
320
321
|
replace_markers: function(new_markers){
|
321
|
-
|
322
|
-
this.markers =
|
323
|
-
//
|
324
|
-
this.bounds = new google.maps.LatLngBounds();
|
322
|
+
//reset previous markers
|
323
|
+
this.markers = new Array;
|
324
|
+
//reset Auto-adjust
|
325
|
+
this.bounds = new google.maps.LatLngBounds();
|
326
|
+
//reset sidebar content if exists
|
327
|
+
if (this.markers_conf.list_container != null ){
|
328
|
+
var ul = document.getElementById(this.markers_conf.list_container);
|
329
|
+
ul.innerHTML = "";
|
330
|
+
}
|
331
|
+
//add new markers
|
325
332
|
this.add_markers(new_markers);
|
326
333
|
},
|
327
334
|
|
328
335
|
//add new markers to on an existing map (beware, it doesn't check duplicates)
|
329
336
|
add_markers: function(new_markers){
|
337
|
+
//clear the whole map
|
338
|
+
this.clear_markers();
|
339
|
+
//update the list of markers to take into account
|
330
340
|
this.markers = this.markers.concat(new_markers);
|
341
|
+
//put markers on the map
|
331
342
|
this.setup_Markers();
|
343
|
+
//adjust map
|
332
344
|
this.adjust();
|
333
345
|
},
|
334
346
|
|
335
347
|
//Creates Marker from the markers passed + markerClusterer
|
336
348
|
setup_Markers: function () {
|
337
|
-
//resets Clusterer if needed
|
338
|
-
if (this.markerClusterer) {
|
339
|
-
this.markerClusterer.clearMarkers();
|
340
|
-
}
|
341
349
|
// Add markers to the map
|
342
350
|
for (var i = 0; i < this.markers.length; ++i) {
|
351
|
+
//check if the marker has not already been created
|
352
|
+
if (!this.exists(this.markers[i].google_object)) {
|
343
353
|
//test if value passed or use default
|
344
354
|
var marker_picture = this.exists(this.markers[i].picture) ? this.markers[i].picture : this.markers_conf.picture;
|
345
355
|
var marker_width = this.exists(this.markers[i].width) ? this.markers[i].width : this.markers_conf.width;
|
@@ -367,12 +377,11 @@ var Gmaps4Rails = {
|
|
367
377
|
var image = new google.maps.MarkerImage(marker_picture, new google.maps.Size(marker_width, marker_height) );
|
368
378
|
var ThisMarker = new google.maps.Marker({position: myLatLng, map: this.map, icon: image, title: marker_title});
|
369
379
|
}
|
370
|
-
//save object
|
371
|
-
this.markers[i].
|
380
|
+
//save object
|
381
|
+
this.markers[i].google_object = ThisMarker;
|
372
382
|
//add infowindowstuff + list creation if enabled
|
373
383
|
this.handle_info_window(this.markers[i]);
|
374
|
-
|
375
|
-
this.marker_objects.push(ThisMarker);
|
384
|
+
}
|
376
385
|
}
|
377
386
|
this.setup_Clusterer();
|
378
387
|
},
|
@@ -381,7 +390,7 @@ var Gmaps4Rails = {
|
|
381
390
|
//create the infowindow
|
382
391
|
var info_window = new google.maps.InfoWindow({content: marker_container.description });
|
383
392
|
//add the listener associated
|
384
|
-
google.maps.event.addListener(marker_container.
|
393
|
+
google.maps.event.addListener(marker_container.google_object, 'click', this.openInfoWindow(info_window, marker_container.google_object));
|
385
394
|
if (this.markers_conf.list_container)
|
386
395
|
{
|
387
396
|
var ul = document.getElementById(this.markers_conf.list_container);
|
@@ -390,7 +399,7 @@ var Gmaps4Rails = {
|
|
390
399
|
aSel.href = 'javascript:void(0);';
|
391
400
|
var html = this.exists(marker_container.sidebar) ? marker_container.sidebar : "Marker";
|
392
401
|
aSel.innerHTML = html;
|
393
|
-
aSel.onclick = this.generateTriggerCallback(marker_container.
|
402
|
+
aSel.onclick = this.generateTriggerCallback(marker_container.google_object, 'click');
|
394
403
|
li.appendChild(aSel);
|
395
404
|
ul.appendChild(li);
|
396
405
|
}
|
@@ -419,7 +428,13 @@ var Gmaps4Rails = {
|
|
419
428
|
{
|
420
429
|
if (this.markers_conf.do_clustering == true)
|
421
430
|
{
|
422
|
-
|
431
|
+
var gmarkers_array = new Array;
|
432
|
+
for (var i = 0; i < this.markers.length; ++i) {
|
433
|
+
gmarkers_array.push(this.markers[i].google_object);
|
434
|
+
}
|
435
|
+
|
436
|
+
|
437
|
+
this.markerClusterer = new MarkerClusterer(this.map, gmarkers_array, { maxZoom: this.markers_conf.clusterer_maxZoom,
|
423
438
|
gridSize: this.markers_conf.clusterer_gridSize,
|
424
439
|
//styles: styles TODO: offer clusterer customization
|
425
440
|
});
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmaps4rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 4
|
10
|
+
version: 0.7.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Benjamin Roth
|