I want to access objects in a my dynamic variable
$scope.positionindifferentplaces = [ {
"DeviceName" : "Device 1",
"DeviceID" : "10000005",
"Date" : "2017-09-22T03:35:38-05:00",
"Latitude" : 12.9716,
"Longitude" : 77.5946,
"Type" : "GPS",
"Speed(mph)" : 64,
"Speed(km/h)" : 103,
"Altitude(ft)" : 68,
"Altitude(m)" : 21,
"Accuracy" : 5
}, {
"DeviceName" : "Device 2",
"DeviceID" : "10000005",
"Date" : "2017-09-22T03:35:38-05:00",
"Latitude" : 17.3850,
"Longitude" : 78.4867,
"Type" : "GPS",
"Speed(mph)" : 64,
"Speed(km/h)" : 103,
"Altitude(ft)" : 68,
"Altitude(m)" : 21,
"Accuracy" : 5
}, {
"DeviceName" : "Device 3",
"DeviceID" : "10000005",
"Date" : "2017-09-22T03:35:38-05:00",
"Latitude" : 21.2514,
"Longitude" : 81.6296,
"Type" : "GPS",
"Speed(mph)" : 64,
"Speed(km/h)" : 103,
"Altitude(ft)" : 68,
"Altitude(m)" : 21,
"Accuracy" : 5
}, {
"DeviceName" : "Device 4",
"DeviceID" : "10000005",
"Date" : "2017-09-22T03:35:38-05:00",
"Latitude" : 28.7041,
"Longitude" : 77.1025,
"Type" : "GPS",
"Speed(mph)" : 64,
"Speed(km/h)" : 103,
"Altitude(ft)" : 68,
"Altitude(m)" : 21,
"Accuracy" : 5
}]
I just want to access latitude and Longitude form this value the required variable is something like this
var directionCoordinates = [ {
lat : 12.9716,
lng : 77.5946
}, {
lat : 17.3850,
lng : 78.4867
}, {
lat : 21.2514,
lng : 81.6296
}, {
lat : 28.7041,
lng : 77.1025
} ];
I want to make that variable dynamic i have tried something like this
for (var i = 0; i < positionindifferentplaces .length; ++i) {
var directionCoordinates = {
lat :$scope.positionindifferentplaces [i].Latitude,
lng :$scope.positionindifferentplaces [i].Longitude }; }
but it's not working please help me with this