Skip to content

Commit 8ef0cbc

Browse files
committed
Add latest builds
1 parent d8dd9ba commit 8ef0cbc

File tree

4 files changed

+131
-26
lines changed

4 files changed

+131
-26
lines changed

build/scripts/ng-map.debug.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,12 @@ angular.module('ngMap', []);
722722
'use strict';
723723
var NgMap, $timeout, NavigatorGeolocation;
724724

725+
var requestTimeout, routeRequest;
726+
// Delay for each route render to accumulate all requests into a single one
727+
// This is required for simultaneous origin\waypoints\destination change
728+
// 20ms should be enough to merge all request data
729+
var routeRenderDelay = 20;
730+
725731
var getDirectionsRenderer = function(options, events) {
726732
if (options.panel) {
727733
options.panel = document.getElementById(options.panel) ||
@@ -757,13 +763,30 @@ angular.module('ngMap', []);
757763
}
758764

759765
var showDirections = function(request) {
760-
directionsService.route(request, function(response, status) {
761-
if (status == google.maps.DirectionsStatus.OK) {
762-
$timeout(function() {
763-
renderer.setDirections(response);
764-
});
766+
if (requestTimeout) {
767+
for (var attr in request)
768+
{
769+
if (request.hasOwnProperty(attr))
770+
{
771+
routeRequest[attr] = request[attr];
772+
}
765773
}
766-
});
774+
}
775+
else
776+
{
777+
requestTimeout = $timeout(function() {
778+
if (!routeRequest)
779+
{
780+
routeRequest = request;
781+
}
782+
directionsService.route(routeRequest, function(response, status) {
783+
if (status == google.maps.DirectionsStatus.OK) {
784+
renderer.setDirections(response);
785+
}
786+
});
787+
requestTimeout = undefined;
788+
}, routeRenderDelay);
789+
}
767790
};
768791

769792
if (request.origin && request.destination) {
@@ -799,6 +822,11 @@ angular.module('ngMap', []);
799822
var events = parser.getEvents(scope, filtered);
800823
var attrsToObserve = parser.getAttrsToObserve(orgAttrs);
801824

825+
var attrsToObserve = [];
826+
if (!filtered.noWatcher) {
827+
attrsToObserve = parser.getAttrsToObserve(orgAttrs);
828+
}
829+
802830
var renderer = getDirectionsRenderer(options, events);
803831
mapController.addObject('directionsRenderers', renderer);
804832

@@ -1064,7 +1092,7 @@ angular.module('ngMap', []);
10641092
* set options
10651093
*/
10661094
var options = parser.getOptions(filtered, {scope: scope});
1067-
options.data = $window[attrs.data] || scope[attrs.data];
1095+
options.data = $window[attrs.data] || parseScope(attrs.data, scope);
10681096
if (options.data instanceof Array) {
10691097
options.data = new google.maps.MVCArray(options.data);
10701098
} else {
@@ -1079,6 +1107,13 @@ angular.module('ngMap', []);
10791107
console.log('heatmap-layer options', layer, 'events', events);
10801108

10811109
mapController.addObject('heatmapLayers', layer);
1110+
1111+
//helper get nexted path
1112+
function parseScope( path, obj ) {
1113+
return path.split('.').reduce( function( prev, curr ) {
1114+
return prev[curr];
1115+
}, obj || this );
1116+
}
10821117
}
10831118
}; // return
10841119
}]);
@@ -1989,7 +2024,7 @@ angular.module('ngMap', []);
19892024
* @example
19902025
* Usage:
19912026
* <map MAP_ATTRIBUTES>
1992-
* <shape name=SHAPE_NAME ANY_SHAPE_OPTIONS ANY_SHAPE_EVENTS"></MARKER>
2027+
* <shape name="SHAPE_NAME ANY_SHAPE_OPTIONS ANY_SHAPE_EVENTS"></shape>
19932028
* </map>
19942029
*
19952030
* Example:

build/scripts/ng-map.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,12 @@ angular.module('ngMap', []);
731731
'use strict';
732732
var NgMap, $timeout, NavigatorGeolocation;
733733

734+
var requestTimeout, routeRequest;
735+
// Delay for each route render to accumulate all requests into a single one
736+
// This is required for simultaneous origin\waypoints\destination change
737+
// 20ms should be enough to merge all request data
738+
var routeRenderDelay = 20;
739+
734740
var getDirectionsRenderer = function(options, events) {
735741
if (options.panel) {
736742
options.panel = document.getElementById(options.panel) ||
@@ -766,13 +772,30 @@ angular.module('ngMap', []);
766772
}
767773

768774
var showDirections = function(request) {
769-
directionsService.route(request, function(response, status) {
770-
if (status == google.maps.DirectionsStatus.OK) {
771-
$timeout(function() {
772-
renderer.setDirections(response);
773-
});
775+
if (requestTimeout) {
776+
for (var attr in request)
777+
{
778+
if (request.hasOwnProperty(attr))
779+
{
780+
routeRequest[attr] = request[attr];
781+
}
774782
}
775-
});
783+
}
784+
else
785+
{
786+
requestTimeout = $timeout(function() {
787+
if (!routeRequest)
788+
{
789+
routeRequest = request;
790+
}
791+
directionsService.route(routeRequest, function(response, status) {
792+
if (status == google.maps.DirectionsStatus.OK) {
793+
renderer.setDirections(response);
794+
}
795+
});
796+
requestTimeout = undefined;
797+
}, routeRenderDelay);
798+
}
776799
};
777800

778801
if (request.origin && request.destination) {
@@ -808,6 +831,11 @@ angular.module('ngMap', []);
808831
var events = parser.getEvents(scope, filtered);
809832
var attrsToObserve = parser.getAttrsToObserve(orgAttrs);
810833

834+
var attrsToObserve = [];
835+
if (!filtered.noWatcher) {
836+
attrsToObserve = parser.getAttrsToObserve(orgAttrs);
837+
}
838+
811839
var renderer = getDirectionsRenderer(options, events);
812840
mapController.addObject('directionsRenderers', renderer);
813841

@@ -1073,7 +1101,7 @@ angular.module('ngMap', []);
10731101
* set options
10741102
*/
10751103
var options = parser.getOptions(filtered, {scope: scope});
1076-
options.data = $window[attrs.data] || scope[attrs.data];
1104+
options.data = $window[attrs.data] || parseScope(attrs.data, scope);
10771105
if (options.data instanceof Array) {
10781106
options.data = new google.maps.MVCArray(options.data);
10791107
} else {
@@ -1088,6 +1116,13 @@ angular.module('ngMap', []);
10881116
void 0;
10891117

10901118
mapController.addObject('heatmapLayers', layer);
1119+
1120+
//helper get nexted path
1121+
function parseScope( path, obj ) {
1122+
return path.split('.').reduce( function( prev, curr ) {
1123+
return prev[curr];
1124+
}, obj || this );
1125+
}
10911126
}
10921127
}; // return
10931128
}]);
@@ -1997,7 +2032,7 @@ angular.module('ngMap', []);
19972032
* @example
19982033
* Usage:
19992034
* <map MAP_ATTRIBUTES>
2000-
* <shape name=SHAPE_NAME ANY_SHAPE_OPTIONS ANY_SHAPE_EVENTS"></MARKER>
2035+
* <shape name="SHAPE_NAME ANY_SHAPE_OPTIONS ANY_SHAPE_EVENTS"></shape>
20012036
* </map>
20022037
*
20032038
* Example:

build/scripts/ng-map.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/scripts/ng-map.no-dependency.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,12 @@ angular.module('ngMap', []);
731731
'use strict';
732732
var NgMap, $timeout, NavigatorGeolocation;
733733

734+
var requestTimeout, routeRequest;
735+
// Delay for each route render to accumulate all requests into a single one
736+
// This is required for simultaneous origin\waypoints\destination change
737+
// 20ms should be enough to merge all request data
738+
var routeRenderDelay = 20;
739+
734740
var getDirectionsRenderer = function(options, events) {
735741
if (options.panel) {
736742
options.panel = document.getElementById(options.panel) ||
@@ -766,13 +772,30 @@ angular.module('ngMap', []);
766772
}
767773

768774
var showDirections = function(request) {
769-
directionsService.route(request, function(response, status) {
770-
if (status == google.maps.DirectionsStatus.OK) {
771-
$timeout(function() {
772-
renderer.setDirections(response);
773-
});
775+
if (requestTimeout) {
776+
for (var attr in request)
777+
{
778+
if (request.hasOwnProperty(attr))
779+
{
780+
routeRequest[attr] = request[attr];
781+
}
774782
}
775-
});
783+
}
784+
else
785+
{
786+
requestTimeout = $timeout(function() {
787+
if (!routeRequest)
788+
{
789+
routeRequest = request;
790+
}
791+
directionsService.route(routeRequest, function(response, status) {
792+
if (status == google.maps.DirectionsStatus.OK) {
793+
renderer.setDirections(response);
794+
}
795+
});
796+
requestTimeout = undefined;
797+
}, routeRenderDelay);
798+
}
776799
};
777800

778801
if (request.origin && request.destination) {
@@ -808,6 +831,11 @@ angular.module('ngMap', []);
808831
var events = parser.getEvents(scope, filtered);
809832
var attrsToObserve = parser.getAttrsToObserve(orgAttrs);
810833

834+
var attrsToObserve = [];
835+
if (!filtered.noWatcher) {
836+
attrsToObserve = parser.getAttrsToObserve(orgAttrs);
837+
}
838+
811839
var renderer = getDirectionsRenderer(options, events);
812840
mapController.addObject('directionsRenderers', renderer);
813841

@@ -1073,7 +1101,7 @@ angular.module('ngMap', []);
10731101
* set options
10741102
*/
10751103
var options = parser.getOptions(filtered, {scope: scope});
1076-
options.data = $window[attrs.data] || scope[attrs.data];
1104+
options.data = $window[attrs.data] || parseScope(attrs.data, scope);
10771105
if (options.data instanceof Array) {
10781106
options.data = new google.maps.MVCArray(options.data);
10791107
} else {
@@ -1088,6 +1116,13 @@ angular.module('ngMap', []);
10881116
void 0;
10891117

10901118
mapController.addObject('heatmapLayers', layer);
1119+
1120+
//helper get nexted path
1121+
function parseScope( path, obj ) {
1122+
return path.split('.').reduce( function( prev, curr ) {
1123+
return prev[curr];
1124+
}, obj || this );
1125+
}
10911126
}
10921127
}; // return
10931128
}]);
@@ -1997,7 +2032,7 @@ angular.module('ngMap', []);
19972032
* @example
19982033
* Usage:
19992034
* <map MAP_ATTRIBUTES>
2000-
* <shape name=SHAPE_NAME ANY_SHAPE_OPTIONS ANY_SHAPE_EVENTS"></MARKER>
2035+
* <shape name="SHAPE_NAME ANY_SHAPE_OPTIONS ANY_SHAPE_EVENTS"></shape>
20012036
* </map>
20022037
*
20032038
* Example:

0 commit comments

Comments
 (0)