geoservicesapi

Java Client for using geo-services using Yelp, Mapquest APIs.

View the Project on GitHub ranesr/geoservicesapi

JAVA Client for using places search service from Yelp and directions and location services from MapQuest APIs

This JAVA Client can help you to request data from different APIs such as Yelp API - Places Services, and MapQuest API - Directions, Location Services.

Motivation

While working on one of the projects, I developed this and thought sharing it with you all. Maybe someone will need it.

Some web apps may require this for finding all the places around a location. And this library can be directly used for doing this just by adding it to your code. You can also create REST API for your own application.

Example

'Places Service'

PlacesServices is a class for consuming places services using Yelp Places API and MapQuest Geo-coding API.

It will show all the places according the search term stated in imported Yelp.java.

//Initialize the service using keys given by Yelp and MapQuest APIs
//Import Yelp.java

String consumerKey = "YOUR YELP CONSUMER KEY";
String consumerSecret = "YOUR YELP CONSUMER SECRET";
String token = "YOUR YELP TOKEN";
String tokenSecret = "YOUR YELP TOKEN SECRET";
String mapquestKey = "YOUR YELP MAPQUEST KEY"

PlacesServices service = new PlacesServices(consumerKey, consumerSecret, token, tokenSecret, mapquestKey);

String lat = "32.780140";
String lng = "-96.800451"
JSONObject venues = service.getVenues(lat, lng);

'Directions Services'

DirectionsServices is a class for consuming directions services using MapQuest Directions API.

//Initialize the service using MapQuest API key
String mapquestKey = "YOUR MAPQUEST KEY"

DirectionsServices service = new DirectionsServices(mapquestKey);

You can get a route between two locations using the following method.

//Source location
String source = "32.780140,-96.800451";
//Destination location
String destination = "30.267153,-97.743061";

JSONObject route = service.getRoute(source, destination);

It can also be used to find the midway between two locations on the road(approximately).

Instead of getRoute() method, call the following method with same arguments.

JSONObject midpoint = service.getMidpoint(source, destination);

'Location Services'

LocationServices is a class for consuming location services using MapQuest Geo-coding API.

//Initialize the service using MapQuest API key
String mapquestKey = "YOUR MAPQUEST KEY"

LocationServices service = new LocationServices(mapquestKey);

You can get geo-location of an address.

String address = "1500 Marilla Street, Dallas, TX, 75201";
JSONObject coordinates = service.getCoordinatesUsingAddress(address);

You can also get geo-location of an address if you know the components of the address.

String street = "1500 Marilla Street";
String city = "Dallas";
String state = "TX";
String postalCode = "75201";

JSONObject coordinates = service.getCoordinatesUsingComponents(street, city, state, postalCode);

You can get the address of a location using its geo-coordinates.

String lat = "32.777333";
String lng = "-96.797090"

JSONObject location = service.getAddress(lat, lng);

Authors and Contributors

@ranesr

README Template by @jxson

Copyright and License

Copyright (C) 2014 @ranesr

Apache License, Version 2.0

Contact

If you want to suggest anything, please contact me at saurabhrrane@gmail.com.