Commit fd2755b5 authored by Deployer's avatar Deployer

Updated to the last cedarmaps api and mapbox-0.7.4

parent 3c9262b2
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
version = "0.7.3"
version = "0.7.4"
def siteUrl = 'http://cedarmaps.com'
def gitUrl = 'http://cedarmaps.com/git'
group = "com.cedarmaps"
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionCode 3
versionName "0.7.3"
targetSdkVersion 23
versionCode 4
versionName "0.7.4"
}
buildTypes {
}
......@@ -22,7 +22,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.3@aar') {
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.4@aar') {
transitive = true
}
}
......
package com.cedarstudios.cedarmapssdk;
import android.util.Pair;
import com.cedarstudios.cedarmapssdk.auth.OAuth2Support;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.json.JSONObject;
public interface CedarMaps extends OAuth2Support, CedarMapsBase {
/**
* Forward Geocoding. This API call needs a valid access token.
*
* @param searchTerm Wherever you want to get info about
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject geocode(String searchTerm) throws CedarMapsException;
JSONObject geocode(String searchTerm, String city) throws CedarMapsException;
/**
* Forward Geocoding. This API call needs a valid access token.
*
* @param searchTerm Wherever you want to get info about
* @param type Possible values are: locality, roundabout, street, freeway, expressway, boulevard (You can mix types by separating them with ",")
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject geocode(String searchTerm, String type) throws CedarMapsException;
/**
* Forward Geocoding. This API call needs a valid access token.
*
* @param searchTerm Wherever you want to get info about
* @param type Possible values are: locality, roundabout, street, freeway, expressway, boulevard (You can mix types by separating them with ",")
* @param limit Number of results
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject geocode(String searchTerm, String type, int limit) throws CedarMapsException;
/**
* Forward Geocoding. This API call needs a valid access token.
*
* @param searchTerm Wherever you want to get info about
* @param location Center point. should be accompanied with distance param
* @param distance Distance from location. Unit is km, 0.1 means 100 meters
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject geocode(String searchTerm, LatLng location, float distance) throws CedarMapsException;
/**
* Forward Geocoding. This API call needs a valid access token.
*
* @param searchTerm Wherever you want to get info about
* @param location Center point. should be accompanied with distance param
* @param distance Distance from location. Unit is km, 0.1 means 100 meters
* @param type Possible values are: locality, roundabout, street, freeway, expressway, boulevard (You can mix types by separating them with ",")
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject geocode(String searchTerm, LatLng location, float distance, String type) throws CedarMapsException;
JSONObject geocode(String searchTerm, String city, double lat, double lng)
throws CedarMapsException;
/**
* Forward Geocoding. This API call needs a valid access token.
*
* @param searchTerm Wherever you want to get info about
* @param location Center point. should be accompanied with distance param
* @param distance Distance from location. Unit is km, 0.1 means 100 meters
* @param type Possible values are: locality, roundabout, street, freeway, expressway, boulevard (You can mix types by separating them with ",")
* @param limit Number of results
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject geocode(String searchTerm, LatLng location, float distance, String type, int limit) throws CedarMapsException;
JSONObject geocode(String searchTerm, String city, double lat, double lng, long distance)
throws CedarMapsException;
JSONObject geocode(String searchTerm, String city, double lat, double lng, long distance,
int limit) throws CedarMapsException;
/**
* Forward Geocoding. This API call needs a valid access token.
*
* @param searchTerm Wherever you want to get info about
* @param location Center point. should be accompanied with distance param
* @param distance Distance from location. Unit is km, 0.1 means 100 meters
* @param ne Specifies north east of the bounding box - should be accompanied with sw param
* @param sw Specifies south west of the bounding box - should be accompanied with ne param
* @param type Possible values are: locality, roundabout, street, freeway, expressway, boulevard (You can mix types by separating them with ",")
* @param limit Number of results
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject geocode(String searchTerm, LatLng location, float distance, LatLng ne, LatLng sw, String type, int limit) throws CedarMapsException;
/**
* Gives an address based on a provided LatLng pair. This API call needs a valid access token.
*
* @param lat
* @param lng
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject geocode(double lat, double lng) throws CedarMapsException;
/**
* This method calculates the distance between points in meters. It can be called with up to 50 different points in a single request.
* This API call needs a valid access token.
*
* @param location1 Starting point
* @param location2 Ending point
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject distance(LatLng location1, LatLng location2) throws CedarMapsException;
/**
* This method calculates the distance between points in meters. It can be called with up to 15 pairs
* This API call needs a valid access token.
*
* @param locationPairs Set up to 15 pairs
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject distance(Pair<LatLng, LatLng>[] locationPairs) throws CedarMapsException;
/**
* Gives all localities in a city wih geometry in GeoJSON format.
* @param city City name in English or Persian
* @return Results as JSONObject
* @throws CedarMapsException
*/
JSONObject locality(String city) throws CedarMapsException;
}
package com.cedarstudios.cedarmapssdk;
import android.text.TextUtils;
import android.util.Pair;
import com.cedarstudios.cedarmapssdk.auth.Authorization;
import com.cedarstudios.cedarmapssdk.auth.NullAuthorization;
import com.cedarstudios.cedarmapssdk.auth.OAuth2Authorization;
import com.cedarstudios.cedarmapssdk.config.Configuration;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
......@@ -11,8 +15,6 @@ import com.squareup.okhttp.Response;
import org.json.JSONException;
import org.json.JSONObject;
import android.text.TextUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Locale;
......@@ -30,30 +32,37 @@ class CedarMapsImpl extends CedarMapsBaseImpl implements CedarMaps {
}
@Override
public JSONObject geocode(String searchTerm, String city) throws CedarMapsException {
return geocode(searchTerm, city, Double.NaN, Double.NaN);
public JSONObject geocode(String searchTerm, String type) throws CedarMapsException {
return geocode(searchTerm, type, 30);
}
@Override
public JSONObject geocode(String searchTerm, String city, double lat, double lng)
throws CedarMapsException {
return geocode(searchTerm, city, lat, lng, -1);
public JSONObject geocode(String searchTerm, String type, int limit) throws CedarMapsException {
return geocode(searchTerm, null, -1, null, null, type, limit);
}
@Override
public JSONObject geocode(String searchTerm, String city, double lat, double lng,
long distance) throws CedarMapsException {
return geocode(searchTerm, city, lat, lng, distance, 30);
public JSONObject geocode(String searchTerm, LatLng location, float distance) throws CedarMapsException {
return geocode(searchTerm, location, distance, null, null, null, 30);
}
@Override
public JSONObject geocode(String searchTerm, String city, double lat, double lng,
long distance, int limit) throws CedarMapsException {
public JSONObject geocode(String searchTerm, LatLng location, float distance, String type) throws CedarMapsException {
return geocode(searchTerm, location, distance, null, null, type, 30);
}
@Override
public JSONObject geocode(String searchTerm, LatLng location, float distance, String type, int limit) throws CedarMapsException {
return geocode(searchTerm, location, distance, null, null, type, limit);
}
@Override
public JSONObject geocode(String searchTerm, LatLng location, float distance, LatLng ne, LatLng sw, String type, int limit)
throws CedarMapsException {
String term;
if (TextUtils.isEmpty(conf.getMapId())) {
throw new CedarMapsException(new NullPointerException(
"mapId is null. please provide a mapId in configuration"));
throw new CedarMapsException(new NullPointerException("mapId is null. please provide a mapId in configuration"));
}
try {
......@@ -61,20 +70,24 @@ class CedarMapsImpl extends CedarMapsBaseImpl implements CedarMaps {
} catch (UnsupportedEncodingException e) {
throw new CedarMapsException(e);
}
String url = String
.format(Locale.ENGLISH, conf.getAPIBaseURL() + "geocode/%s/%s.json",
conf.getMapId(), term);
String url = String.format(Locale.ENGLISH, conf.getAPIBaseURL() + "geocode/%s/%s.json", conf.getMapId(), term);
url += String.format(Locale.ENGLISH, "?limit=%s", limit);
if (!TextUtils.isEmpty(city)) {
url += String.format(Locale.ENGLISH, "&city=%s", city);
if (location != null) {
url += String.format(Locale.ENGLISH, "&location=%1$s,%2$s&distance=%3$s", location.getLatitude(), location.getLongitude(), distance);
}
if (ne != null) {
url += String.format(Locale.ENGLISH, "&ne=%1$s,%2$s", ne.getLatitude(), ne.getLongitude());
}
if (!Double.valueOf(lat).isNaN() && !Double.valueOf(lng).isNaN()) {
url += String.format(Locale.ENGLISH, "&location=%1$s,%2$s", lat, lng);
if (sw != null) {
url += String.format(Locale.ENGLISH, "&sw=%1$s,%2$s", sw.getLatitude(), sw.getLongitude());
}
if (distance != -1) {
url += String.format(Locale.ENGLISH, "&distance=%s", distance);
if (!TextUtils.isEmpty(type)) {
url += String.format(Locale.ENGLISH, "&type=%s", type);
}
try {
......@@ -87,14 +100,62 @@ class CedarMapsImpl extends CedarMapsBaseImpl implements CedarMaps {
@SuppressWarnings("SpellCheckingInspection")
@Override
public JSONObject geocode(double lat, double lng) throws CedarMapsException {
String url = String.format(Locale.ENGLISH,
conf.getAPIBaseURL() + "geocode/%1$s/%2$s,%3$s.json", conf.getMapId(), lat, lng);
if (TextUtils.isEmpty(conf.getMapId())) {
throw new CedarMapsException(new NullPointerException("mapId is null. please provide a mapId in configuration"));
}
String url = String.format(Locale.ENGLISH, conf.getAPIBaseURL() + "geocode/%1$s/%2$s,%3$s.json", conf.getMapId(), lat, lng);
try {
return new JSONObject(getDataFromAPI(url));
} catch (JSONException e) {
throw new CedarMapsException(e);
}
}
@Override
public JSONObject distance(LatLng location1, LatLng location2) throws CedarMapsException {
if (TextUtils.isEmpty(conf.getMapId())) {
throw new CedarMapsException(new NullPointerException("mapId is null. please provide a mapId in configuration"));
}
String url = String.format(Locale.ENGLISH, conf.getAPIBaseURL() + "distance/%1$s/%2$s,%3$s;%4$s,%5$s", conf.getMapId(),
location1.getLatitude(), location1.getLongitude(), location2.getLatitude(), location2.getLongitude());
try {
return new JSONObject(getDataFromAPI(url));
} catch (JSONException e) {
throw new CedarMapsException(e);
}
}
@Override
public JSONObject distance(Pair<LatLng, LatLng>[] locationPairs) throws CedarMapsException {
if (TextUtils.isEmpty(conf.getMapId())) {
throw new CedarMapsException(new NullPointerException(
"mapId is null. please provide a mapId in configuration"));
throw new CedarMapsException(new NullPointerException("mapId is null. please provide a mapId in configuration"));
}
String pairs = "";
String delimiter = "";
for (Pair<LatLng, LatLng> locationPair : locationPairs) {
pairs += delimiter + String.format(Locale.ENGLISH, "%1$s,%2$s;%3$s,%4$s", locationPair.first.getLatitude(),
locationPair.first.getLongitude(), locationPair.second.getLatitude(), locationPair.second.getLatitude());
delimiter = "/";
}
String url = String.format(Locale.ENGLISH, conf.getAPIBaseURL() + "distance/%1$s/%2$s", conf.getMapId(), pairs);
try {
return new JSONObject(getDataFromAPI(url));
} catch (JSONException e) {
throw new CedarMapsException(e);
}
}
@Override
public JSONObject locality(String city) throws CedarMapsException {
String url = String.format(Locale.ENGLISH, conf.getAPIBaseURL() + "locality/%s.json", city);
try {
return new JSONObject(getDataFromAPI(url));
} catch (JSONException e) {
......
......@@ -3,6 +3,7 @@ package com.cedarstudios.cedarmaps.sample;
public class Constants {
public static final String MAPID_CEDARMAPS_STREETS = "cedarmaps.streets";
public static final String MAPID_CEDARMAPS_DRIVING = "cedarmaps.driving";
public static final String CLIENT_ID = "";
public static final String CLIENT_SECRET = "";
}
package com.cedarstudios.cedarmaps.sample.fragment;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.cedarstudios.cedarmaps.sample.Constants;
import com.cedarstudios.cedarmaps.sample.MainActivity;
import com.cedarstudios.cedarmaps.sample.R;
......@@ -18,23 +35,6 @@ import com.mapbox.mapboxsdk.views.MapView;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class APIAdvancedGeocodeTestFragment extends Fragment implements View.OnClickListener {
......@@ -139,8 +139,8 @@ public class APIAdvancedGeocodeTestFragment extends Fragment implements View.OnC
.build();
CedarMaps cedarMaps = new CedarMapsFactory(configuration).getInstance();
searchResult = cedarMaps.geocode(params[0], "tehran", 35.6961, 51.4231, 3000,
5);
LatLng location = new LatLng(35.6961, 51.4231);
searchResult = cedarMaps.geocode(params[0], location, 50, null, 5);
} catch (CedarMapsException e) {
e.printStackTrace();
}
......@@ -160,28 +160,19 @@ public class APIAdvancedGeocodeTestFragment extends Fragment implements View.OnC
JSONArray array = jsonObject.getJSONArray("results");
for (int i = 0; i < array.length(); i++) {
JSONObject item = array.getJSONObject(i);
String[] location = item.getJSONObject("location").getString("center")
.split(",");
LatLng latLng = new LatLng(Double.parseDouble(location[0]),
Double.parseDouble(location[1]));
String[] location = item.getJSONObject("location").getString("center").split(",");
LatLng latLng = new LatLng(Double.parseDouble(location[0]), Double.parseDouble(location[1]));
Marker marker = new Marker(mapView, item.getString("name"), "", latLng);
marker.setIcon(
new Icon(getActivity(), Icon.Size.MEDIUM, "marker-stroked",
"FF0000"));
marker.setIcon(new Icon(getActivity(), Icon.Size.MEDIUM, "marker-stroked", "FF0000"));
mapView.addMarker(marker);
}
} else if (status.equals("ZERO_RESULTS")) {
Toast.makeText(getActivity(), getString(R.string.no_results),
Toast.LENGTH_LONG)
.show();
Toast.makeText(getActivity(), getString(R.string.no_results), Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getActivity(), getString(R.string.unkonown_error),
Toast.LENGTH_LONG)
.show();
Toast.makeText(getActivity(), getString(R.string.unkonown_error), Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Toast.makeText(getActivity(), getString(R.string.parse_error),
Toast.LENGTH_LONG).show();
Toast.makeText(getActivity(), getString(R.string.parse_error), Toast.LENGTH_LONG).show();
}
}
}
......
package com.cedarstudios.cedarmaps.sample.fragment;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.cedarstudios.cedarmaps.sample.Constants;
import com.cedarstudios.cedarmaps.sample.MainActivity;
import com.cedarstudios.cedarmaps.sample.R;
......@@ -18,23 +35,6 @@ import com.mapbox.mapboxsdk.views.MapView;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class APIGeocodeTestFragment extends Fragment implements View.OnClickListener {
......@@ -92,8 +92,7 @@ public class APIGeocodeTestFragment extends Fragment implements View.OnClickList
if (!TextUtils.isEmpty(mSearchEditText.getText().toString())) {
InputMethodManager inputManager = (InputMethodManager) getActivity()
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
clearMarkers();
......@@ -130,8 +129,7 @@ public class APIGeocodeTestFragment extends Fragment implements View.OnClickList
JSONObject searchResult = null;
try {
SharedPreferences pref = getActivity().getSharedPreferences(MainActivity.PREF_NAME,
Context.MODE_PRIVATE);
SharedPreferences pref = getActivity().getSharedPreferences(MainActivity.PREF_NAME, Context.MODE_PRIVATE);
Configuration configuration = new ConfigurationBuilder()
.setOAuth2AccessToken(pref.getString(MainActivity.PREF_ID_ACCESS_TOKEN, ""))
......
......@@ -16,7 +16,7 @@ repositories {
}
dependencies {
compile('com.cedarmaps:CedarMapsSDK:0.7.3@aar') {
compile('com.cedarmaps:CedarMapsSDK:0.7.4@aar') {
transitive = true
}
}
......@@ -76,8 +76,8 @@ To add the `MapView` as a layout element, add the following to your xml file:
```xml
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
android:layout_width="match_parent"
android:layout_height="match_parent" />
```
......@@ -228,7 +228,7 @@ com.cedarstudios.cedarmapssdk.config.Configuration
Then you should use `oAuth2Token` with each API call
#### Geocode (Street Search)
#### Geocode (Place Search)
For finding a street you can easily call streetSearch method.
......@@ -248,42 +248,55 @@ The output would be something like this for search term "همت":
{
"results": [
{
"address": "المهدی",
"id": 301568,
"location": {
"bb": {
"ne": "35.770861600000003,51.323841700000003",
"sw": "35.770540400000002,51.323066400000002"
},
"center": "35.770585227006897,51.323426168064202"
},
"name": "همت",
"type": "street"
"address": "اراضی عباس آباد,مهران,سید خندان,...",
"components": {
"city": "تهران",
"country": "ایران",
"districts": [
"منطقه 4",
"منطقه 3"
],
"localities": [
"اراضی عباس آباد",
"مهران",
"سید خندان",
"پاسداران"
],
"province": "تهران"
},
{
"address": "کاظم آباد,مهران,اراضی عباس آباد,...",
"id": 397432,
"id": 429874,
"location": {
"bb": {
"ne": "35.759246099999999,51.4836156",
"ne": "35.756689799999997,51.464761500000002",
"sw": "35.7491463,51.423702800000001"
},
"center": "35.749153889854,51.427947792189102"
"center": "35.749155599171999,51.428327751596903"
},
"name": "همت",
"type": "expressway"
},
{
"address": "ابوذر,شهرابی",
"id": 312434,
"address": "المهدی",
"components": {
"city": "تهران",
"country": "ایران",
"districts": [
"منطقه 5"
],
"localities": [
"المهدی"
],
"province": "تهران"
},
"id": 338756,
"location": {
"bb": {
"ne": "35.679308300000002,51.480144099999997",
"sw": "35.679143099999997,51.478227199999999"
"ne": "35.770861600000003,51.323841700000003",
"sw": "35.770540400000002,51.323066400000002"
},
"center": "35.679225700000003,51.479185649999998"
"center": "35.770585227006897,51.323426168064202"
},
"name": "همتی",
"name": "همت",
"type": "street"
}
],
......@@ -306,32 +319,190 @@ CedarMaps cedarMaps = new CedarMapsFactory(configuration).getInstance();
searchResult = cedarMaps.geocode(lat, lng);
```
The output would be something like this for 35.4,52.3:
The output would be something like this for 35.716482704636825, 51.40897750854492:
```json
{
"result": {
"address": "تهران، شهرک غرب، خیابان دادمان، خیابان سپهر",
"address": "بن بست سروش - زرتشت",
"city": "تهران",
"components": [
{
"long_name": "خیابان سپهر",
"short_name": "سپهر",
"type": "street"
"long_name": "بن بست سروش",
"short_name": "بن بست سروش",
"type": "residential"
},
{
"long_name": "خیابان دادمان",
"short_name": "دادمان",
"type": "steet"
"long_name": "زرتشت",
"short_name": "زرتشت",
"type": "primary"
},
{
"long_name": "شهرک غرب",
"short_name": "شهرک غرب",
"long_name": "بهجت آباد",
"short_name": "بهجت آباد",
"type": "locality"
},
{
"long_name": "تهران",
"short_name": "تهران",
"type": "city"
}
],
"locality": "بهجت آباد",
"traffic_zone": {
"in_central": true,
"in_evenodd": true,
"name": "محدوده طرح ترافیک"
}
},
"status": "OK"
}
```
#### Distance
This method calculates the distance between points in meters. It can be called with up to 50 different points in a single request.
The only supported profile is cedarmaps.driving which calculates the distance using car routing.
```java
Configuration configuration = new ConfigurationBuilder()
.setOAuth2AccessToken(oAuth2Token.getAccessToken())
.setOAuth2TokenType(oAuth2Token.getTokenType())
.setMapId(Constants.MAPID_CEDARMAPS_DRIVING)
.build();
CedarMaps cedarMaps = new CedarMapsFactory(configuration).getInstance();
searchResult = cedarMaps.distance(new LatLng(35.6961, 51.4231), new LatLng(35.744625, 51.374600));
```
Response elements:
distance: The overall distance of the route, in meter
time: The overall time of the route, in ms
bbox: The bounding box of the route, format: minLon, minLat, maxLon, maxLat
The output would be something like this:
```json
{
"result": {
"routes": [
{
"bbox": [
51.368587,
35.74982,
51.41652,
35.762383
],
"distance": 7516.338,
"time": 500912
}
]
},
"status": "OK"
}
```
#### Locality
It gives you all localities in a city wih geometry in GeoJSON format. This API call needs a valid access token.
```java
Configuration configuration = new ConfigurationBuilder()
.setOAuth2AccessToken(oAuth2Token.getAccessToken())
.setOAuth2TokenType(oAuth2Token.getTokenType())
.build();
CedarMaps cedarMaps = new CedarMapsFactory(configuration).getInstance();
searchResult = cedarMaps.locality("tehran");
```
Supported cities are: tehran, تهران
The output would be something like this:
```json
{
"results":
[
{
"geometry": {
"coordinates": [
[
[
51.3904371,
35.6144373
],
[
51.3860088,
35.6143914
],
[
51.3896979,
35.6169901
],
[
51.3893829,
35.6216496
],
[
51.3869264,
35.622008
],
[
51.3863595,
35.6257456
],
[
51.384092,
35.6256944
],
"locality": "شهرک غرب"
[
51.38384,
35.6281007
],
[
51.3821393,
35.6281007
],
[
51.378927,
35.6348585
],
[
51.378602,
35.6384921
],
[
51.3822129,
35.6370245
],
[
51.385588,
35.637117
],
[
51.3859658,
35.6313776
],
[
51.3916527,
35.6247423
],
[
51.3904371,
35.6144373
]
]
],
"type": "Polygon"
},
"name": "اسفندیاری و بستان"
}
],
"status": "OK"
}
```
......
......@@ -5,8 +5,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
......@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment