I am a newcomer to AngularJS and I am attempting to pass my JSON latitude and longitude based on ID into the Google API. Here is the structure of my JSON file:
{
"totalCount":206,
"deals":[{
"id":"2",
"Name":"samir",
"locations":[{
"location":"Mundhwa Gaon",
"address":"Mundhwa Gaon, North Main Road, Pune - 411 001",
"latLon":"18.53918870,73.90790910"
},
"location":"Mundhwa Gaon",
"address":"Mundhwa Gaon, North Main Road, Pune - 411 001",
"latLon":"18.53918870,73.90790910"
},
]
},
"id":"3",
"Name":"samir",
"locations":[{
"location":"Mundhwa Gaon",
"address":"Mundhwa Gaon, North Main Road, Pune - 411 001",
"latLon":"18.53918870,73.90790910"
},
"location":"Mundhwa Gaon",
"address":"Mundhwa Gaon, North Main Road, Pune - 411 001",
"latLon":"18.53918870,73.90790910"
},
]
}]
}
Here is my AngularJS code:
$http({method: 'GET', url: '/api/v1/asas}).success(function(data) {
$scope.deal = data.deals;
if(data.deals[0].hasOwnProperty("locations") && data.deals[0].locations!=null){
var location=$scope.deal[0].locations[0]['latLon'];
var locationlatlong=location.split(",");
$scope.map = {center: {latitude: locationlatlong[0], longitude: locationlatlong[1] }, zoom: 4 }
$scope.options = {scrollwheel: false};
var markers = [];
for (var i = 0; i < $scope.deal[0].locations.length; i++) {
markers.push(createmarker(i, $scope.deal[0].locations[i]['location'], $scope.deal[0].locations[i]['latLon'],$scope.deal[0].locations[i]['address']))
}
$scope.markers = markers;
if(badBrowser){
$scope.rendermap=false;
}else{
$scope.rendermap=true;
}
}
});
Currently, it only passes the location of the first deal ID. I am trying to implement a functionality where clicking on a deal will pass that deal's ID location (latitude and longitude). My AngularJS version is 1.2.23.