I am developing an app which given a postal code will return map of the area with all the roads in the 100m radius highlighted either green red or yellow based on our machine learning algorithm. My task is 2-folded
Gather all the roads in 100m radius given Postal code
Highlight those roads using different colours
Our solution to the very first problem is quite inefficient atm, we are trying to convert the postal code to LatLng and then calculate boundary boxes with LatLng +/- 100m and extract street names. This sadly uses so much bandwidth AND API calls that we must look for a new solution. Is there anything we could use instead?
As of highlighting those roads that are another problem, as I have encountered problems where the application needs to highlight specific route, which was solved using polylines based off points google maps API returned. In this case, though, no points are returned as of now.
I know that those are 2 question but they are so closely related to each other (as the output of 1st problem will be used in the drawing lines) that I've decided to ask them together.
Really appreciate your help!
In case people are wondering how to solve similar question here's how we solved it:
Our current solution is sending the initial Postal Code and radius to OpenStreetMap API called overpass (http://wiki.openstreetmap.org/wiki/Overpass_API) which returns streets within given bounding box (which is calculated using postal code longitude and latitude) as a WAY (set of points in JSON format). The returned WAY can be easily visualised using polylines included in the google maps API.
Hope that helps!
Related
Alongside with my friends I am about to develop an android application. The application will use maps a lot, finding routes, placing markers, drawing predefined routes, stuff like that.
There is this Google Maps APIv2. So I tried it, write some code and looks good. I am able to place markers and draw polylines, however my application will have some predefined routes. One route is set of LatLng points. So I just add these points to PolylineOptions and add it to map. Great, it works.
But these predefined routes will be created in web-based application also using Google Maps APIv2 or similar api/library. Some streets are not straight they are curved so you need to create a lot of LatLng points to get it look nice which is very important. I can do this but I want to put only two LatLng points - at the beginning of the street and at the end.
Here is the image:
On the left, route has only two LatLng points (red dots) and that is desired shape of line. On the right same route with 2 LatLng points gives me route coloured in light blue, and this is what actually happens if I just add polyline to GoogleMap object. In order to create same effect as in left image, I need to create many LatLng (red dots) points which is not appropriate for those who will create these routes. So this leads us to routing problem which can be solved by using Google Directions API. Which solves the problem of drawing routes with less markers. Basically what I understood, this API for directions actually creates a lot of these LatLng points that I draw using for-each loop as seen on right part of picture above. And I need to contact Google Web Service for this so I need to have Internet connection - and this is the problem.
Sometimes internet will not be available hence I need some alternative solution. I've heard of Open Street Maps, but I am not sure how to use it and does it needs internet connection for creating these routes.
Is there any free library that offers offline routing and showing maps offline? Basically all map interactions must be done without use of internet.
But it is understandable if internet connection is needed only for the first run of application as it is needed for Google Maps APIv2, well application crashes until I turn on internet, after which any next run I do not need internet..
A web based application will be made for creating these routes and routes will be created by users for whom we develop this application. And as users can be very annoying they will demand some user-friendly and easy interface for creating routes. Telling them that they need to create 100 to 500 points for each route, and if there is 60-70 routes they will gladly say NO to our application.
Any advice? If it is possible, I can write my own routing algorithm for Google Maps to work offline, I am very skilful at "Algorithms and Data Structures" - any guides/tutorials for this? But I guess this map is just set of tiles, and does not have necessary information for finding route.... So please correct If I am mistaken for anything.
You can use the Scout SDK (provides a free usage quota) as it offers full offline maps, routing & navigation.
Have a look into the open source projects GraphHopper, Mapsforge and OpenScience-VTM which can do routing and/or maps offline. And all use OpenStreetMap data. Other projects exists of course, have a look here and here.
Also have a look into the GraphHopper map matching component which could be interesting for your specific use case and can work offline too.
(Note I'm the author of GraphHopper)
If it is possible, I can write my own routing algorithm for Google Maps to work offline
No you can't, the data is not open nor you can buy the data to my knowledge.
Another option is OsmAnd. The OSM wiki also has some information about OsmAnd and even more information about OSM on Android in general as well as pages about rendering and routing.
I'm not sure if this belongs in StackOverflow as it's not technically coding, but I can't think of where this would belong.
Currently, we're working on a mobile application that we're thinking of using the Google Maps API to return the start and end of a street's intersections in a particular suburb.
For example, if Suburb A encompasses half of Street B, it will only highlight that section of Street B.
After reading the following articles (Getting long/lat points of a suburb, getting start/end co-ords of a street), they basically summarise that
I believe that Google does not expose the information about the suburb's boundary. You could store the points in boundary yourself, and display them with a Polygon.
and
The Google Maps API v3 doesn't do that. You need to find a different data source or manually determine the coordinates.
so obviously that eliminates Google Maps. Is there any other map API that can be used both on mobile and web browsers that can display these highlighted street points?
Another option we are considering is that we manually insert the co-ordinates into a database and have the application/s read from that, and do as the first linked answer sort of implies, manually draw the routes?
Please don't hesitate to let me know if this question needs modification or to be moved to another exchange.
Great question, and I think found the answer (note this is for Australia, but a similar process could work elsewhere).
http://www.datalicious.com/blog/2012/03/19/free-australian-suburb-boundary-data-for-mapp/
This might help. They:
We used the Australian Bureau of Statistics data, which offers the suburb boundaries as an ESRI shapefile. This data in essence offers the perimeters of every suburb in Australia using GPS coordinates. The ABS offers some its boundary data in more friendly formats, but many are not – hence the blog post. The process involved importing the ESRI shapefile into an open-source program called Quantum GIS that allowed an export of the suburb boundaries into a format we could work with (i.e. CSV format).
If you could pull coordinates out of this you could then use this in google maps to find the suburb boundaries concerning the streets you want, and only select the section of the street within the suburb you want.
I'm sure there are other solutions, but I don't think it is possible directly through the Google Maps API (as indicated here: Accessing google maps area coordinates (suburb boundaries)).
I'm working in an Android application that will use Google directions service.
The source location is determined by the GPS and the destination is set by the user, the user can also set some waypoints by touching in the MapView (this is optional). Finally the app draws the route between these points.
When invoking the Google directions service I get a list of "steps", as far as I'm concerned each step corresponds to a point where the driver has to turn (right?). Is it posible to get more steps? For example consider each corner of the path as a step?
Thanks in advance.
Finally I could draw a precise route by decoding the "polyline" of each step returned by the service. A polyline contains an object holding an array of encoded points that represents an approximate path.
So I decoded that into a List of GeoPoints and then drew the lines between those GeoPoints.
In case someone needs to do something similar, this was really useful to me:
Google Maps API Version difference
Hi With the help of LocationManager I managed to find current location in android.
For showing routes between two geo- co-ordinates what should I use so that I wont plot air distance instead will show ground routes or is it with help of json can I plot routes.
I have tried polyLine() but it gives straight line.
To work out the line between two points you need to know what map projection type you are using. Some map projections preserve shape (and therefore angles) others do not. Take a look at http://www.progonos.com/furuti/MapProj/Dither/CartProp/ShapePres/shapePres.html it might help.
If you're using a Mercator projection then I found this page that claims an algorithm in C# that should point you on your way: http://conceptdev.blogspot.co.uk/2009/01/great-circles.html
As for the line segments, ployline will give stright lines between the points. You'll need to use Path and use the Bézier curve methods Path.cubicTo() and Path.rCubicTo() from memory.
Do you have all permission set in the Manifest? Also, you have to enable the location service (is the gps icon in the status bar showing?). It'll take some time for the device to get the location, so see if onLocationChanged is called.
Here you can find the answer for your qustion:
Is there a way to show road directions in Google Map API v2?
and here:
Get driving directions using Google Maps API v2
basically what you should do is make a call to Google Directions API receive the road direction coordinates (many Latlng points), and then draw a polyline between each one of them.
I am building a web app which contains a Google Maps link that can be opened by the native phone Maps app (iPhone/Android).
The link has the form:
http://maps.google.com/?q="+startCooLat+','+startCooLng;
and I have also tried the:
http://maps.google.com/?q=loc:"+startCooLat+'+'+startCooLng;
However in the native app the marker is positioned in the nearest street and not in the exact coordinates that I am giving. Is there a solution or another parameter to set so as to overcome this issue?
Instead of questioning (q=.....) google maps for the location, in which it returns what it thinks is the nearest human address to the location (somewhat annoying I think) you can pass a lat lng location where you want the center of the map to be. For example:
http://maps.google.co.uk/?ll=53.385517,-1.865315
Instead of:
http://maps.google.co.uk/?q=53.385517,-1.865315
I had this problem my self, and on my Android device at least this works. The second example simply puts the map on a road, the first is in the middle of the moors on the device in the maps app.
The full link from the comments:
http://maps.google.com/maps?ll=53.385517,-1.865315&q=loc:53.385517,-1.865315&t=m
This one seems to work at adding a marker for the standard maps app whilst still adding a marker.
After receiving a recent answer to an old Android Google Maps question I had, I have found another solution to this question, which I thought would be useful for others. Original Question - and credit to Captain Charmi for pointing me in the direction.
Instead of using the link above which will create a marker at the given location, trouble is, the maker is pretty meaningless, just the coordinates. If you use the following link, you can add either a title to the marker and show the coordinates:
http://maps.google.com/maps?q=53.385517,-1.865315+(My Random Location)
Or you can instead of adding a title, you can supply text to go inside the marker:
http://maps.google.com/maps?q=A pot of gold at the end of a rainbow#53.385517,-1.865315
As you can see, Google now drops the marker in the correct place due to being supplied the info for the marker. I hope this helps.