I have a project in progress where users need to click on a specific location, which will then take them to that location using Google Maps. The locations are stored as an array of objects, and here is how the location files are structured.
$scope.SiteLocs = [
{
"name": "502 Nelson St, Greenville, MS 38701",
"visibility": "0",
"description": "502 Nelson St, Greenville, MS 38701",
"styleUrl": "#waypoint",
"Point": { "coordinates": "-91.05636,33.415485,0" }
},
{
"name": "242 Blackhawk Trace, Galena, IL 61036",
"visibility": "0",
"description": "242 Blackhawk Trace, Galena, IL 61036",
"styleUrl": "#waypoint",
"Point": { "coordinates": "-90.319778,42.390862,0" }
},
{
"name": "3747 Ocean Dr, Vero Beach, FL 32963",
"visibility": "0",
"description": "3747 Ocean Dr, Vero Beach, FL 32963",
"styleUrl": "#waypoint",
"Point": { "coordinates": "-80.358248,27.659094,0" }
}, etc...
My goal is to add another element to each item in the array. I attempted to use the .concat()
method, but it didn't yield the desired outcome.
If I wish to include "carrier": "sprint"
for each location, how can I achieve that?
I also neglected to mention this piece of code. It involves splitting and rearranging the coordinates in the files.
angular.forEach($scope.SiteLocs, function(location) {
var clength = location.Point.coordinates.length;
if (location.Point.coordinates.substring(clength - 2, clength) === ",0") {
location.Point.coordinates = location.Point.coordinates.substring(0, clength - 2).split(",");
Lat = location.Point.coordinates[0]
Lon = location.Point.coordinates[1]
Com = ","
location.Point.coordinates = Lon.concat(Com,Lat)
}