dylanfprice / angular-gm

AngularJS Google Maps Directives
MIT License
198 stars 47 forks source link

RichMarker as directive. #49

Closed Vahanerevan closed 10 years ago

Vahanerevan commented 10 years ago

Hi is there a way to add richmarker as directive http://google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/examples/richmarker.html ? Currently I use $interpolate service to create template and add html , but it needs to be updated every time I want to update content only.

JohnLindahlTech commented 10 years ago

This is an issue for me too, have not found any solution yet though.

Vahanerevan commented 10 years ago

FOUND.

// in conrtroller
var cache =  {};
var c;
$scope.getMarkerOptions = function(marker) {

           if(!cache[marker.id]){
             cache[marker.id]  = $compile('<marker item="markers['+marker.id+']"></marker>')($scope);
           }
           c =cache[marker.id];
            return  {
                shadow:'none',
                content:c[0]
            };

        };

//directive
App.directive('marker', function() {
  return  {
    scope:{
      item:'='
    },
    restrict: 'E',
    link: function(scope, element, attrs) {
     // some code
    },
    templateUrl: 'some-html-file.html',
    replace: true,

  };

});