From 283c3e8aa4d2ea18c6d13dbdc08d997d37fcaaeb Mon Sep 17 00:00:00 2001 From: Timothy Wood Date: Thu, 27 Feb 2014 10:26:24 -0500 Subject: [PATCH 1/3] added inside callback for geofences --- gmaps.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gmaps.js b/gmaps.js index 19b174df..53d49d5f 100644 --- a/gmaps.js +++ b/gmaps.js @@ -535,6 +535,7 @@ GMaps.prototype.createMarker = function(options) { details = options.details, fences = options.fences, outside = options.outside, + inside = options.inside, base_options = { position: new google.maps.LatLng(options.lat, options.lng), map: null @@ -544,6 +545,7 @@ GMaps.prototype.createMarker = function(options) { delete options.lng; delete options.fences; delete options.outside; + delete options.inside; var marker_options = extend_object(base_options, options), marker = new google.maps.Marker(marker_options); @@ -622,7 +624,11 @@ GMaps.prototype.createMarker = function(options) { if (marker.fences) { google.maps.event.addListener(marker, 'dragend', function() { self.checkMarkerGeofence(marker, function(m, f) { - outside(m, f); + if( typeof outside != "undefined") + outside(m, f); + }, function(m, f) { + if( typeof inside != "undefined") + inside(m, f); }); }); } @@ -1512,12 +1518,14 @@ GMaps.prototype.checkGeofence = function(lat, lng, fence) { return fence.containsLatLng(new google.maps.LatLng(lat, lng)); }; -GMaps.prototype.checkMarkerGeofence = function(marker, outside_callback) { +GMaps.prototype.checkMarkerGeofence = function(marker, outside_callback, inside_callback) { if (marker.fences) { for (var i = 0, fence; fence = marker.fences[i]; i++) { var pos = marker.getPosition(); if (!this.checkGeofence(pos.lat(), pos.lng(), fence)) { outside_callback(marker, fence); + } else { + inside_callback(marker, fence); } } } From 76caa8df0a02d21cf70889f2872703746d261230 Mon Sep 17 00:00:00 2001 From: Timothy Wood Date: Thu, 27 Feb 2014 10:27:01 -0500 Subject: [PATCH 2/3] added inside callback for geofences --- lib/gmaps.geofences.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/gmaps.geofences.js b/lib/gmaps.geofences.js index 74797c87..35383998 100644 --- a/lib/gmaps.geofences.js +++ b/lib/gmaps.geofences.js @@ -2,12 +2,14 @@ GMaps.prototype.checkGeofence = function(lat, lng, fence) { return fence.containsLatLng(new google.maps.LatLng(lat, lng)); }; -GMaps.prototype.checkMarkerGeofence = function(marker, outside_callback) { +GMaps.prototype.checkMarkerGeofence = function(marker, outside_callback, inside_callback) { if (marker.fences) { for (var i = 0, fence; fence = marker.fences[i]; i++) { var pos = marker.getPosition(); if (!this.checkGeofence(pos.lat(), pos.lng(), fence)) { outside_callback(marker, fence); + } else { + inside_callback(marker, fence); } } } From 6ce86bbdebaf761f133065545486d36b2ea4fe39 Mon Sep 17 00:00:00 2001 From: Timothy Wood Date: Thu, 27 Feb 2014 10:27:22 -0500 Subject: [PATCH 3/3] added inside callback for geofences --- lib/gmaps.markers.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/gmaps.markers.js b/lib/gmaps.markers.js index 718268d3..6556d199 100644 --- a/lib/gmaps.markers.js +++ b/lib/gmaps.markers.js @@ -7,6 +7,7 @@ GMaps.prototype.createMarker = function(options) { details = options.details, fences = options.fences, outside = options.outside, + inside = options.inside, base_options = { position: new google.maps.LatLng(options.lat, options.lng), map: null @@ -16,6 +17,7 @@ GMaps.prototype.createMarker = function(options) { delete options.lng; delete options.fences; delete options.outside; + delete options.inside; var marker_options = extend_object(base_options, options), marker = new google.maps.Marker(marker_options); @@ -94,7 +96,11 @@ GMaps.prototype.createMarker = function(options) { if (marker.fences) { google.maps.event.addListener(marker, 'dragend', function() { self.checkMarkerGeofence(marker, function(m, f) { - outside(m, f); + if( typeof outside != "undefined") + outside(m, f); + }, function(m, f) { + if( typeof inside != "undefined") + inside(m, f); }); }); }