codeforamerica / fast_pass

Las Vegas Development Opportunity Finder
BSD 3-Clause "New" or "Revised" License
7 stars 4 forks source link

Map popups and Angular: How to do? #15

Closed louh closed 11 years ago

louh commented 11 years ago

Map popups should be Angular templates so that content / data in them can also be bound in the Angular app.

How to trigger? Usually events on the map (like a click) are done via the leaflet.js library itself. Does adding an ng-click to the map work? Can / should leaflet's event listener fire Angular directives?

EDIT:

This issue should be reworded / rephrased now that the map is using Google Maps API. Map events are working property and so are popups. Right now the challenge is binding infowindow content to Angular models. Why it's not working out of the box:

Solutions (how to implement??)

louh commented 11 years ago

Figured out a workable solution. The magic words are:

$scope.infowindow.setContent('content')

https://developers.google.com/maps/documentation/javascript/infowindows

The setContent() takes care of updating the info window. This is NOT an Angular data-binding solution. The logic for compiling the HTML will need to happen in the controller to output to the map view. However, because the method changes the DOM itself, we don't need to have a promise to wait for the data fetching/compiling to happen first.