S
S
Seva2015-08-04 22:18:29
Angular
Seva, 2015-08-04 22:18:29

How to pass variable from $scope on click to Google Maps marker?

<map center="50.4501, 30.5234" zoom="11" style="height: 100%" data-tap-disabled="true">
    <marker ng-repeat="item in items" on-click="go({{item.id}})" position="{{item.coords}}">
    </marker>
</map>

ng-click inside the marker doesn't work, you need to use google's on-click.
item.id he does not see and passes the coordinates of the market.
Has anyone come across?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Kononenko, 2015-08-06
@premas

Use normal Google Maps, put a bind('click', callback) on each marker at the end of each $scope.$apply() callback.
If you want to cheat, then do this:

<marker data-item="{{item.id}}" ng-repeat="item in items" onclick="go(this.dataset.item)" position="{{item.coords}}">
</marker>

And in the handler, which will have to be declared inside the controller as a global window function, take this date attribute accordingly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question