I am trying to add map markers dynamically to the map using ng-repeat inside ng-map as follows,
<div id="map-canvas">
<ng-map default-style="true">
<marker id='ID{{school.id}}' ng-repeat="school in vm.schools" position="{{school.location}}" on-click="vm.showDetail(school)" icon="assets/img/marker-excellent.png">
</marker>
<info-window id="marker-info">
<div ng-non-bindable="">
<h5>{{vm.school.name}}</h5>
</div>
</info-window>
</ng-map>
</div>
Here this creates multiple markers with the same marker icon. I want to use different marker icons based on the value of {{school.rating}}. However I am not able to figure out how to change the marker icon url based on the value of rating while the ng-repeat is in action to render the markers on the map.
Currently, I am doing the following, but I think this is an inefficient method of doing it.
<div id="map-canvas">
<ng-map default-style="true">
<marker id='ID{{school.id}}' ng-if="school.overallRating >= 4.5" ng-repeat="school in filteredSchools = (search.schools | filter:boardsFilter)" position="{{school.location}}" on-click="search.showDetail(school)" icon="assets/img/marker-excellent.png">
</marker>
<marker id='ID{{school.id}}' ng-if="school.overallRating < 4.5 && school.overallRating >= 3.5" ng-repeat="school in filteredSchools = (search.schools | filter:boardsFilter)" position="{{school.location}}" on-click="search.showDetail(school)" icon="assets/img/marker-good.png">
</marker>
<marker id='ID{{school.id}}' ng-if="school.overallRating < 3.5 && school.overallRating >= 2.0" ng-repeat="school in filteredSchools = (search.schools | filter:boardsFilter)" position="{{school.location}}" on-click="search.showDetail(school)" icon="assets/img/marker-average.png">
</marker>
<info-window id="marker-info">
<div ng-non-bindable="">
<h5>{{vm.school.name}}</h5>
</div>
</info-window>
</ng-map>
</div>
Here, I have put multiple marker directives each having ng-repeat but different conditions using ng-if
I am wondering if there is a more efficient way to do it using a single marker directive with ng-repeat