【发布时间】:2014-09-08 15:05:11
【问题描述】:
我正在使用 Bing 地图 AJAX 控件来显示地图。 我已经为我想放在地图上的图钉创建了一个 Angular 指令:
app.directive('myPin', function(){
return {
restrict: 'E',
templateUrl: '<p>{{title}}</p>'
}
})
在我的 Angular 控制器中,我设置了地图,然后将 (a) Pin(s) 添加到它,如下所示:
// Define the title for the Pin
$scope.title = 'Test title';
// Define the location and the options for the Pin
var location = new Microsoft.Maps.Location(52.48, 13.42);
var pushpinOptions = {
width: null,
height: null,
htmlContent: '<my-pin></my-pin>'
};
// Push the Pin onto the map
map.entities.push(new Microsoft.Maps.Pushpin(location, pushpinOptions));
很遗憾,但很明显,我的自定义图钉也没有显示在地图上,因为“htmlContent”部分是由 Bing 服务动态注入到 DOM 中的。我已经尝试了很多 Angular 的 $compile 服务,但我不知道如何让它工作......
【问题讨论】:
-
嗨,你有没有在这方面取得任何进展,因为我遇到了完全相同的问题
标签: angularjs angularjs-directive bing-maps angularjs-compile