I have a plain array in JavaScript:
$scope.myArray = [{ "coords" : { "lat" : 0, "long" : 0 } }, { "coords" : { "lat" : 1, "long" : 1 } }, { "coords" : { "lat" : 2, "long" : 2 } }];
Then, I have the angular-google-maps module, to draw these points as paths to the screen.
<ui-gmap-google-map center='map.center' zoom='map.zoom'>
<ui-gmap-polyline path="myArray" stroke="p.stroke" visible='p.visible' geodesic='p.geodesic' fit="false" editable="p.editable" draggable="p.draggable" icons='p.icons'>
</ui-gmap-polyline>
</ui-gmap-google-map>
This directive, however, expects path to by an array of positions, like this:
$scope.myArray = [{ "lat" : 0, "long" : 0 }, { "lat" : 1, "long" : 1 }, { "lat" : 2, "long" : 2 }];
Is there any way to simply transform between my first array to the one the ui-gmap-polyline expects? I was thinking about writing a filter, but I'm not sure if that's the best way. Positions will be added (and possibly changed) to myArray, and I want the Google Map to update along with this. Another way would be to watch myArray for changes and create a new array every time to feed to the Map, but there seems to be a very simple solution I'm missing.
e.g.: path="myArray | filter:coords"
-> is there any way to filter an array to only return certain fields of each element?
Edit: myArray is a synchronised $firebaseArray (https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebasearray). This array is updated by the Firebase API automatically when the backend is updated (out of my control).