我要访问在我的动态变量访问对象的JavaScript
$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
}]
我只是想获得纬度和经度形式此值 所需的变量对象是这样的
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
} ];
我想使这个变量的动态我已经试过这样的事情
for (var i = 0; i < positionindifferentplaces .length; ++i) {
var directionCoordinates = {
lat :$scope.positionindifferentplaces [i].Latitude,
lng :$scope.positionindifferentplaces [i].Longitude }; }
但它不工作,请帮助我这个