Recently, I started working with AngularJS and I've been attempting to pass my JSON data containing latitude and longitude values to the Google Maps API. Here's 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"
},
]
}]
}
Below is the AngularJS code I'm using:
$http({method: 'GET', url: '/api/v1/asas}).success(function(data) {
$scope.deal = data.deals;
if(data.deals.hasOwnProperty("locations") && data.deals.locations!=null){
var location=$scope.deal.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.locations.length; i++) {
markers.push(createmarker(i, $scope.deal.locations[i]['location'], $scope.deal.locations[i]['latLon'],$scope.deal.locations[i]['address']))
}
$scope.markers = markers;
if(browserUnsupported){
$scope.showMap=false;
}else{
$scope.showMap=true;
}
}
});
However, I'm encountering an issue with the if condition because it's not getting the expected value. My AngularJS version is 1.2.23.