Reputation: 25
I'm new to servlet and jsp, I want to make a simple application using Java servlets or JSP that get the locations of some places using Google maps and then do some calculations, then display the results on the map in a webpage. I can request places search using this :
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522%2C151.1957362&radius=500&types=bus_station&sensor=false&key=YOURAPIKEY.
It returns a JSON array, but I don't know how to call this link inside java code. or how to send the location from java-script to servlets.
Simply I want to apply algorithm written in java and calls data from Google maps also return outputs on map.
Upvotes: 0
Views: 4261
Reputation: 2435
Integrating Maps into Your Java Web Application with Google Maps and Ajax (V2 !!)
https://today.java.net/pub/a/today/2006/10/25/integrating-google-maps-into-web-application.html
Upvotes: 0
Reputation: 741
Use HTMLUnit: http://htmlunit.sourceforge.net/
It will simulate browser action so you can post whatever you want and have an appropriate method handle the callback.
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnScriptError(false);
try {
UnexpectedPage page = webClient.getPage(url);
InputStream inputStream = page.getInputStream();
// Read the stream
} catch (IOException e) {
e.printStackTrace();
}
Upvotes: 0
Reputation: 6039
You can use URLConnection to call the link from Java code and XMLHTTPRequest to send the location from browser (javascript) to the servlet.
Upvotes: 1