I'm working on a project where I need to get the JSON Response and display markers in Google Map. When I try to get JSON response from .json test file, it works fine (Code is provided below). But When I try similar code to get JSON response from remote URL it doesn't work. I'm not sure where I'm missing.
Code with geoLocationDataSet.json Test File.
getPetsLocations: function (lat, lng, max) {
return $.getJSON("data/geoLocationDataSet.json") ;
},
Input Data Set in geoLocationDataSet.json File:
[
{
"type":"LOST",
"alertID":"320",
"petID":"11534",
"dateTime":"03\/14\/2017",
"petName":"Samson",
"ownerName":"TEMP_Haywood",
"reward":"100",
"distance":"7",
"latitude":"27.9506",
"longitude":"-82.3672",
"place":"Greater Palm River Point CDC 33619",
"image":null
},
{
"type":"LOST",
"alertID":"328",
"petID":"11132",
"dateTime":"03\/14\/2017",
"petName":"Tucker",
"ownerName":"TEMP_Phyliss",
"reward":"0",
"distance":"12",
"latitude":"27.9506",
"longitude":"-82.2872",
"place":"Villa Place 33510",
"image":"https:\/\/s3.amazonaws.com\/petimage\/58c857b9c7ee8"
}
]
Now this is the code for Remote URL that doesn't work, I'm getting response but when I try to return data it's not able to return expected data set like above example, not able to show markers in Google Map.
getPetsLocations: function (lat, lng, max) {
//alert('Before call..');
$.getJSON("http://dev.mywaggintales.com/pets/d_lostfound.php?mce=27.939224,-82.462295&mra=25&mem=chholloway@me.com&mac=1234", function(data){
alert(JSON.stringify(data.ds_petAlert[1]));
return data.ds_petAlert[1];
});
},
I'm not exactly sure where I'm missing. IT would be great if you please take a look at it and let me know the issue with above code when I parse JSON data and return it.