I'm working with a basic JavaScript array:
$scope.myArray = [{ "coords" : { "lat" : 0, "long" : 0 } }, { "coords" : { "lat" : 1, "long" : 1 } }, { "coords" : { "lat" : 2, "long" : 2 }];
Next, I want to utilize the angular-google-maps module to display these points as paths on 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>
The ui-gmap-polyline directive, however, requires the path to be an array of positions in simple format like this:
$scope.myArray = [{ "lat" : 0, "long" : 0 }, { "lat" : 1, "long" : 1 }, { "lat" : 2, "long" : 2 }];
Is there an efficient way to convert my initial complex array into the format expected by ui-gmap-polyline? I was considering using a filter but unsure if it's the most effective approach. Any new elements added or changed in myArray should automatically update on the Google Map. Another option could be to watch for changes in myArray and generate a new array each time for mapping purposes, but I feel there might be a simpler solution that I am overlooking.
e.g.: path="myArray | filter:coords"
-> Can an array be filtered to only extract specific fields from each element?
Edit: Just to note, myArray is a synchronized $firebaseArray (). This array receives automatic updates from the Firebase API when changes occur in the backend (beyond my control).