也许是一个简单的问题,但找不到简单的答案。我的标记上有一个事件处理程序,该事件处理程序使一个InfoWindow弹出,其中带有ng-click
:
google.maps.event.addListener(myMarker, 'click', function() {
var contentString = "<div>Somerandomstring<br/>" +
"<a ng-click='send()'>Send to google maps</a></div>";
var compiled = $compile(contentString)($scope);
infowindow.setContent(compiled[0]);
infowindow.open($scope.map, myMarker);
});
有什么方法可以将
myMarker
的坐标传递给函数send()
?像send(this.position)
一样? 最佳答案
您应该能够使用myMarker.getPosition()
执行以下操作
google.maps.event.addListener(myMarker, 'click', function() {
var location = myMarker.getPosition().toString();
var contentString = "<div>Somerandomstring<br/>" +
"<a ng-click='send(" + location + ")'>Send to google maps</a></div>";
var compiled = $compile(contentString)($scope);
infowindow.setContent(compiled[0]);
infowindow.open($scope.map, myMarker);
});