Skip to content

Commit b841848

Browse files
author
Andrew Sullivan
committed
Merge develop into master
1 parent bc64524 commit b841848

4 files changed

Lines changed: 59 additions & 10 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
node_modules
22
bower_components
3-
.idea

dist/angular-mapbox.js

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
(function() {
281281
'use strict';
282282

283-
angular.module('angular-mapbox').directive('mapbox', function($compile, $q, mapboxService) {
283+
angular.module('angular-mapbox').directive('mapbox', function($compile, $q, $parse, mapboxService) {
284284
var _mapboxMap;
285285

286286
return {
@@ -298,25 +298,53 @@
298298
};
299299
mapboxService.addMapInstance(scope.map, mapOptions);
300300

301+
if (attrs.dragging === 'false') {
302+
scope.map.dragging.disable();
303+
}
304+
if (attrs.touchZoom === 'false') {
305+
scope.map.touchZoom.disable();
306+
}
307+
if (attrs.doubleClickZoom === 'false') {
308+
scope.map.doubleClickZoom.disable();
309+
}
310+
if (attrs.scrollWheelZoom === 'false') {
311+
scope.map.scrollWheelZoom.disable();
312+
}
313+
301314
var mapWidth = attrs.width || 500;
302315
var mapHeight = attrs.height || 500;
303-
element.css('width', mapWidth + 'px');
304-
element.css('height', mapHeight + 'px');
316+
element.css('width', mapWidth + (/^[0-9]+$/.test(mapWidth)?'px':''));
317+
element.css('height', mapHeight + (/^[0-9]+$/.test(mapHeight)?'px':''));
305318

306319
scope.zoom = attrs.zoom || 12;
307320
if(attrs.lat && attrs.lng) {
308321
scope.map.setView([attrs.lat, attrs.lng], scope.zoom);
309322
}
310323

311324
if(attrs.onReposition) {
312-
scope.map.on('dragend', function() {
313-
scope[attrs.onReposition](scope.map.getBounds());
325+
var repositionFn = $parse(attrs.onReposition, null, true);
326+
scope.map.on('dragend', function(event) {
327+
scope.$apply(function() {
328+
repositionFn(scope, {$event:event});
329+
});
314330
});
315331
}
316332

317333
if(attrs.onZoom) {
318-
scope.map.on('zoomend', function() {
319-
scope[attrs.onZoom](scope.map.getBounds());
334+
var zoomFn = $parse(attrs.onZoom, null, true);
335+
scope.map.on('zoomend', function(event) {
336+
scope.$apply(function() {
337+
zoomFn(scope, {$event:event});
338+
});
339+
});
340+
}
341+
342+
if(attrs.onClick) {
343+
var clickFn = $parse(attrs.onClick, null, true);
344+
scope.map.on('click', function(event) {
345+
scope.$apply(function() {
346+
clickFn(scope, {$event:event});
347+
});
320348
});
321349
}
322350

@@ -357,7 +385,7 @@
357385
(function() {
358386
'use strict';
359387

360-
angular.module('angular-mapbox').directive('marker', function($compile, $timeout, mapboxService) {
388+
angular.module('angular-mapbox').directive('marker', function($compile, $timeout, $parse, mapboxService) {
361389
var _colors = {
362390
navy: '#001f3f',
363391
blue: '#0074d9',
@@ -413,6 +441,15 @@
413441
map.locate();
414442
} else {
415443
_marker = addMarker(scope, map, [attrs.lat, attrs.lng], popupContentElement, _opts, _style);
444+
445+
if(attrs.onClick) {
446+
var clickFn = $parse(attrs.onClick, null, true);
447+
_marker.on('click', function() {
448+
scope.$apply(function() {
449+
clickFn(scope, {$event:event});
450+
});
451+
});
452+
}
416453
}
417454
});
418455

0 commit comments

Comments
 (0)