procterw / ng-maps

A Google Maps directive for data intensive AngularJS apps
6 stars 4 forks source link

How to use "properties" in points #15

Open pietro-fragnito opened 8 years ago

pietro-fragnito commented 8 years ago

Is it possible and how use properties array in order to get information on a point when clicked and do some actions?

Thanks

nandorpersanyi commented 7 years ago

If you want to dynamically update the points properties, add the following $watch in the points directive above the coords $watch and it should work:

$scope.$watch('properties', function() {
            properties = $scope.properties;
 });

Than the properties argument should be available in the "options" method in the config object (where you set the points config in the controller). There you can add any value to the points or your property by index (properties[i]) which will be available in the events

$scope.points = {
      coords: [],
      properties:[],
      options: function(coords, properties, i, map) {
        return {
          draggable: false,
          pointProperty: properties[i]
        }
      },
      events: {
        click: function(e, point, map, points) {
          console.log(point) // you should see it set here
        }
      }
    };