Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

fix: Removed map- prefix from event names #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
//then we just use ui-event to catch events from an element
function bindMapEvents(scope, eventsStr, googleObject, element) {
angular.forEach(eventsStr.split(' '), function (eventName) {
//Prefix all googlemap events with 'map-', so eg 'click'
//for the googlemap doesn't interfere with a normal 'click' event
google.maps.event.addListener(googleObject, eventName, function (event) {
element.triggerHandler('map-' + eventName, event);
element.triggerHandler(eventName, event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event will be undefined if methods like setCenter are called on an invisible map. if (!event) return?

//We create an $apply if it isn't happening. we need better support for this
//We don't want to use timeout because tons of these events fire at once,
//and we only need one $apply
Expand Down
13 changes: 8 additions & 5 deletions test/mapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ describe('uiMap', function () {
expect(scope.gmap.getCenter()).toBe(center);
});

it('should pass events to the element as "map-eventname"', function () {
it('should pass events to the element as "eventname"', function () {
scope.zoomy = false;
scope.county = 0;
createMap({}, {
'map-zoom_changed': 'zoomy = true',
'map-dblclick map-dragend': 'county = county + 1'
'zoom_changed': 'zoomy = true',
'dblclick dragend': 'county = county + 1'
});
google.maps.event.trigger(scope.gmap, 'zoom_changed');
expect(scope.zoomy).toBeTruthy();
Expand Down Expand Up @@ -89,13 +89,16 @@ describe('uiMap', function () {
expect(inner.val()).toBe('final');
});

it('should recognize infowindow events in ui-event as "map-eventname"', function () {
it('should recognize infowindow events in ui-event as "eventname"', function () {
expect(scope.closed).toBeUndefined();
dump(scope.closed);
createWindow({}, {
'map-closeclick': 'closed = true'
'closeclick': 'closed = true'
});
createMap();
dump(scope.closed);
google.maps.event.trigger(scope.ginfo, 'closeclick');
dump(scope.ginfo);
expect(scope.closed).toBe(true);
});
});
Expand Down