Google Map APIs : UK specific results - android

I'm developing a map application in Android. I'm using Google maps API to show results in Autocomplete textview dropdown .The results this API is returning is of the places of the entire world . I want to show results o provide solutions to places only of a particular country eg .UK
How should I do it . Is there any specific flag to be set for it .
My URL :
private static String SUGGETION_URL = "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=%s&types=geocode&sensor=true&key=xxxxx.xxx-xxxxx";
Please suggest ways by which this url will return results to places only in UK ?

There's no way to force the API to restrict it's results to a region like you can in some of the other Google Maps Web Service APIs. If you really need that functionality then maybe you should be using the Geocoding API or the Places Autocomplete API as included in the Google Maps JS V3 API.
If you can't use either of those two suggestions your options are limited to:
You can use the location / radius parameters like you found, but there are treated as more like "suggestions" than absolutes.
I'd try setting the language parameter to en-GB which might favor UK-based results slightly over others.

Related

GeoCoords from Android Google Maps SEND Intent

Hello my fellow coders,
I am trying to retrieve GeoCoordinates from an Android Google Maps SEND Intent (as dispatched when selecting to share a selected location) and even after searching around and trying various approaches for hours now I can't seem to get anywhere. However, all I seem to get from the Intent seems to be a text/plain content like this:
Franziskaner Wirtshaus & Biergarten - Trudering-Riem, München
https://some/shortened/maps/link
I tried (amongst others) several approaches from:
Get GeoCodes from Android Google Maps App (Not applicable since it opens a new activity)
How can I find the latitude and longitude from address? (Geocoder and Geocoding REST API from Google - no suitable results)
None of the above solutions yields any usable results.
Is there a reliable way to get GPS coordinates from something a user selected in Google Maps on Android at all?
Thanks in advance for your help,
Alex
I don't know if this app helps you. you can copy coordinates to clipboard or open it with other third party maps
cheers

How can I control my direction type preference in the new Google Maps link URLs?

I would like to be able to have a Google Maps direction link which, when opened on mobile (Android), would bring up directions in Google Maps using a specified direction type (e.g. bicycle).
Using the old Google Maps URL parameters you can do,
https://www.google.com/maps/preview?saddr=[insert_from_address_here]&daddr=[insert_to_address_here]&dirflg=[insert_mode_here]
but it doesn't work on mobile.
Using the new Google Maps URL parameters you can do,
https://www.google.com/maps/dir/[customer address]/[our address]/am=t/
which does work on mobile but I don't know how to specify direction type.
From the Google Forum itself, try this on your URL if this works.
Car /data=!4m2!4m1!3e0
Bicycling /data=!4m2!4m1!3e1
Walking /data=!4m2!4m1!3e2
Public Transit /data=!4m2!4m1!3e3
Airplane /data=!4m2!4m1!3e4
For example
https://www.google.com/maps/dir/747+Howard+St,+San+Francisco,+CA/55+Music+Concourse+Dr,+San+Francisco,+CA/data=!4m2!4m1!3e3
For more information, juct check the link above and this stackexchange question.

how to write a directions request for Google Maps Directions?

I am making an android app that uses the google maps directions services. I have finished almost all of the app but i have a problem with the directions request. I need that the request will give me a bus route and that there will be no transfers. I know i need to use the transit_mode bus ,and the transit_routing_preference fewer_transfers. but i dont know how to add it to the request. do i need to write &transit_mode=bus&transit_routing_preference=fewer_transfers& ?
i looked everywhere but i still dont know how to add those options to the request.
The Google Maps Directions API uses a simple HTTP interface, you're on the right track setting the transit_mode=bus and transit_routing_preference=fewer_transfers. You'll also need to set mode=transit to activate transit mode.
I think the final URL you're looking for will look like:
https://maps.googleapis.com/maps/api/directions/json?origin=Mountain%20View&destination=1600%20Amphitheatre%20Parkway&mode=transit&transit_mode=bus&transit_routing_preference=fewer_transfers&key=YOUR_API_KEY.
Note - The transit_mode and transit_routing_preference parameters will bias your results, but not guarantee the results will always be a bus route with 0 transfers. You'll need to design your application to handle > 0 transfer bus routes.

Google Maps Android API v2 in China - map load took around an hour

What I have: native android app that use Android Maps API v2 (native library)
Everything works good in Hong Kong and Ukraine. The problems came as soon as we step in China border. We have next problems:
Map is loading from 30 mins to about one hour.
Even when it's loaded, the map resolution is very low http://i.gyazo.com/d4f40e1a225bd48a90087c39a502e4a6.png
Google Map WORKS by itself: http://i.gyazo.com/dc85e3618c285ced5bba799053dd0306.png
What I know around China:
Google is not really friendly there, but our app is not the one that is used a google maps in China, so my problem probably is not a new one.
There is the option to use a google maps hosted locally in China - ditu.google.cn, but as soon as we are using the native app there is not an option now to use a web view of map instead of native implementation (we have a lot of customizations)
I know, that better do not use HTTPS with Google maps (you can read around this here: Google Maps Geolocation API for China)
The question is:
Could we somehow improve the load of map? Could we somehow override the google map source to use a ditu.google.cn?
Could we somehow disable HTTPS in Map API?
Any other solution around this problem, that can be applied based on google services. Maybe there is some undocumented features?
What is did not expect as an answer is something like "Use Baidu". I know Baidu and this is a veeerryyy backup option as soon as they have an api docs in chineese.
It's fare to add, that Geocoding API based on ditu.google.cn works good.
Looking forward, thank you!
Maybe you can't override the original tile source. But you can use TileOverlay to get maps tile from external server.
Usage example :
TileProvider tileProvider = new UrlTileProvider(256, 256) {
//...
#Override
public URL getTileUrl(int x, int y, int zoom) {
/* Define the URL pattern for the tile images */
String s = String.format("http://my.image.server/images/%d/%d/%d.png",
zoom, x, y);
if (!checkTileExists(x, y, zoom)) {
return null;
}
try {
return new URL(s);
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
}
//...
}
You can replace the my.image.server with ditu.google.cn and use external server API to get tile images. In the Maps, you can set OnCameraChangeListener, so the application will load tiles from external server when the map is zooming or panning.
Read more : https://developers.google.com/maps/documentation/android/tileoverlay
Google still has no map publishing license in China (at least as my latest info goes) It may well be that in the near future Google's Map services will be blocked.
A lot of Chinese websites, including ours, use Google's JS as well as their Service API's, Among them is Google's geocoding api. in china, baidu (NASDAQ:BIDU) and sogou [the minor search engine, part of sohu (NASDAQ:SOHU)] both provided online maps and also APIs,
baidu’s map api home is http://dev.baidu.com/wiki/map/in...
sogou’s map api home is http://map.sogou.com/api/
actually, in china, as of now, the google maps api are still available now. as from recent chinatech.us news, Google China passed the annual inspection and got more opportunity to get online map business license so, the 3 API are are and available.

how to display result returned from google places api text search in android

I am trying to use Google places api text search in my android application,for finding location on map.So I looked for it and got this query:
"https://maps.googleapis.com/maps/api/place/textsearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&query=cafe&key=My Browser Key"
But I don't Know,how to display the results on map.Can I have any example for getting result and displaying it on map using Google map places api text search feature?

Categories

Resources