Skip to content Skip to sidebar Skip to footer

Google Place Api Is Not Supporting Multiple Types

when i provide the url given below , i am getting the proper rsults but String baseUrl = 'https://maps.googleapis.com/maps/api/place/search/xml?location='; String last='&am

Solution 1:

This works for me when using multiple types:

String keyString = "your_key";

StringJSON_BASE = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=";
String types = "airport|hospital";
try {
        placesSearchStr=JSON_BASE+getLat()+","+getLng()+
                        "&radius=1000&sensor=false&types="+URLEncoder.encode(types,"UTF-8")+
                        "&key="+keyString;
    } catch (UnsupportedEncodingException e) {

        e.printStackTrace();
    }

The emphasis here is on types="+URLEncoder.encode(types,"UTF-8")

Solution 2:

Hi friend i had same problem like you,after long time searching i found another solution for parsing google response using Volley api http://java.dzone.com/articles/android-%E2%80%93-volley-libraryVolley library for Android parse xml response?

volley liabrery has no request for xml but have string request and response, you can convert string into xml format than parse data as xml

Solution 3:

I friend now i got the multiple types support now. use uri builder class request url

public String getURL(double lat, double lng){
    Uriuri=newUri.Builder()
    .scheme("https")
    .authority("maps.googleapis.com")
    .path("maps/api/place/search/xml")
    .appendQueryParameter("location", lat+",",lng)
    .appendQueryParameter("radius", "5000")
    .appendQueryParameter("types",   "zoo|travel_agency|taxi_stand|pet_store|museum|movie_theater|library|jewelry_store|hospital|clothing_store|atm|church|bus_station|art_gallery|bank|beauty_salon|city_hall|book_store|park|shopping_mall|train_station|airport")
    .appendQueryParameter("sensor", "true")
    .appendQueryParameter("key", "your key")
    .build();
    return uri.toString();
}

Solution 4:

Try to put parameters like where types like String types = "cafe|restaurant";:

try {
    HttpRequestFactoryhttpRequestFactory= createRequestFactory(HTTP_TRANSPORT);
    HttpRequestrequest= httpRequestFactory
            .buildGetRequest(newGenericUrl(PLACES_SEARCH_URL));
    request.getUrl().put("key", API_KEY);
    request.getUrl().put("location", _latitude + "," + _longitude);
    request.getUrl().put("radius", _radius); // in meters
    request.getUrl().put("sensor", "false");

    if(types != null)
        request.getUrl().put("types", types);

    PlacesListlist= request.execute().parseAs(PlacesList.class);
    // Check log cat for places response status
    Log.d("Places Status", "" + list.status);
    return list;

} catch (HttpResponseException e) {
    Log.e("Error:", e.getMessage());
    returnnull;
}

Post a Comment for "Google Place Api Is Not Supporting Multiple Types"