I am new to handling JSON data and I am trying to learn it by getting data from the Police API and displaying it on my Google Map.
Basically I want to take in a user input which gets Geocoded and then does a request to “http://policeapi2.rkh.co.uk/api/crimes-street/all-crime?lat=52.629729&lng=-1.131592” (lat and long being the geocoded address).
I have been searching all over, but anything that seems to use cURL (which is what they suggest on their website), gets involved with PHP. There was a good example on richardalan.co.uk, but I have never used PHP in my life and the technologies I am using are Spring MVC, Google App Engine, Google Maps(JavaScript).
I just want to know if I can do it in my JavaScript that has also been used to create functions for my maps and how do I do it?
Thank you in advanced,
Mark
I have now provided this question with a solution
I have done this now using my Spring MVC controllers to GET the JSON data I needed and then displayed it in my page and on a Google Map using JQuery AJAX.
Here is my Controller that gets the JSON data from the Police API:
Here is part of my index.jsp page where I display the JSON data onto the map:
Here is part of my index.jsp page where I loop through the JSON data to display the results to my view and also get the longitude and latitude and send it to my function shown above (I understand this might look messy and there might be a better way to do it, but it works):
Here is part of my index.jsp page where the information gets output to a specific section in index.jsp:
I really do hope this helps someone other than me, as I found I had a hard time understanding AJAX, after I finally understood it, it was actually really easy 🙂