android: show direction in google maps - android

i am developing an android application that use map view.
i can add point to the map, zoom, get current location and animate to point.
but how to get direction between 2 points?
when user click on point to show direction between current location and clicked location.
Thanks

but how to get direction between 2 points?
Math. This has nothing to do with Android. It has little to do with maps, even. It has everything to do with math.
Depending on the distances involved, you might be able to get away with treating things as plain Carteisan coordinates and do the necessary trigonometry. Over a significant distance, though, the curvature of the Earth starts to play a role, and the math will get harder.
You might consider using a search engine to find whatever versions of the formulas you would like to use.

in order to show a direction on maps (android)
you can try to make an Overlaying custom route on your application.
We shall further assume that the route returned may contain additional information such as the local slope of the route (which could be important if one is negotiating the route in a wheelchair, for example). Since this requires a network access that could block the main UI thread if there are network difficulties, we shall also use this example to introduce the important skill of putting time-consuming or potential UI-blocking tasks on a background thread. and use AsyncTask to run the process in the background. To use AsyncTask we must subclass it.
maybe this is helped you out.

Related

I want to create an augmented reality Android app, but I lack the descriptive language to begin

This is the gist of my app idea:
When the user turns on the app, it calculates a position 100 ft in front of them, then overlays some kind of marker onto the camera, so that when the user looks at the position through the phone, they see the marker. Then they can walk towards the marker, which gets bigger (ie "closer") as they walk towards it.
The full idea for the app is more complicated than this, but I think that if I could create this, the rest would just be iterations.
What concepts of AR, mapping, images, Android API, hardware (and anything else I haven't thought of) does this bring to mind that I need to begin learning about? I have lots of programming experience, and some Android experience but next to no AR or vision experience.
Basically, I'm hoping you guys could give me a list of terms to Google so that I can begin forming concrete ideas of how to make this.
Isn't this a kind of 'Geo-Located" AR? To get search results matching what you are describing rather than methods that put the augmented content at a relative distance from the viewer, try searching "latitude", "longitude", "coordinates", "POI" etc., along with AR terms. I am currently looking into learning AWE.js because it offers true geo-located POIs (point(s) of interest) using coordinates.
I came across this (https://github.com/buildar/awe.js/issues/3) when trying to find for myself how to create geo-located POIs using AWE. For your purpose ("...calculates a position 100 ft in front of them, then overlays some kind of marker onto the camera...") you would need a way to leave the x and y axis as they are in the original 'geo_ar' demo (https://github.com/buildar/awe.js/tree/master/examples) - as relative to the user, not as lat/lon coordinates. However, for the user to be able to approach them, you would need to find a way to get them to initially appear as relative to the user (the default way), but then somehow be locked down. It normally wouldn't be necessary because in most apps geo-located POIs are placed near real physical places of some significance, so rather than the user having POIs appear near wherever he is, he goes to find them where they are. I don't know how locking down an initially-relative POI would be done - I am not a programmer, I just stalk programmers online. ;) Still, I hope that fills in some of your gaps to help you get started.
I believe there are games out there (though I haven't played them myself) that do this to spawn enemies like ghosts or zombies. They spawn a set distance away from you, but you have to run from them.

How To Generate A Path As User Changes Location

I'm developing an application which requires the user's path taken to be recorded, and measured. I'm already familiar with utilizing onLocationChanged to receive location change updates, but how could I use these Location points to create a complete path, encompassing their entire trip from one location to another?
I was thinking I could utilize each Location passed as a point, and simply connect all of the points with a polyline, but this seems to me like it would be a weird and slightly ugly line (as location approximations aren't always super-accurate).
Another idea I had would be to acquire each street the user travels down, and then ultimately connect them all, but I'm not even certain as to how I would perform this.
Any ideas?
The best method would be to have some kind of representation of the map,
then keeping your recent locations in a data structure (omitting too close locations by keeping only locations in fixed deltas, for example).
Then you could match the points to nearest roads, and calculate their projection on them to created a matched path on the map.
Since I've implemented this before, I can tell that it involves quite a bit of work, having some representation of the map as a graph (say using OSM), and knowledge with geometric queries (in PL/PGSQL probably if we talk about OSM).
The trigonometric calculation themselves are rather easy and can be found on the web (E.g. projection of point on a given line).
To get quality results, you'll also have to deal with your progress along the route (I.e. filtering gps points that lead you "backwards" instead of "forward" by mistake due to GPS signal error).
You'd better off starting with a working POC:
Depending on your map implementation (Google / OSM)-
Choose some kind of an online routing provider (http://wiki.openstreetmap.org/wiki/Routing/online_routers).
Then you could send small navigation requests between locations you stored earlier. Since their delta is small, you'll probably get the relevant matched path on the road.
Downsides: You depend on an external service and its quota, and can't serve many clients without paying.
Advantages: You could build a working POC in a small amount of time (~hours)
Either way, you'll be bound to the quality of your given map (e.g. updated roads, turn restrictions) that will determine the correctness of your results.

Storing (caching) Google map with given radius and using it while offline

First of all if this one is a duplicate, please refer me to the original thread(s), as I have failed to find the exact thing I was searching for.
Basically for some time now I am developing an application for the client and it was all going well up until this point.
The client requests to be able to
I) While online:
Access Google map
Set the point by clicking on map
Store a portion of the map around the above mentioned point locally as per the radius he/she selected (eg. 3km)
II) While offline:
Access the map he stored in above steps.
The application should draw the path as he moves as per GPS coords received from another device via BT.
The ability to zoom in/out, scroll around map and everything else that standard google map allows.
I am completely lost on this one and would like at least someone to point out the right direction for something like this.
I'm well aware how to handle most of the above while Android device is online, but have no idea how to do this while offline.
I pretty much need help with I-3, II-1, and maybe II-3.
PS. I don't really need BT tutorials and guidance (mentioned in II-2), that part is handled, I just pointed out the source of coords.
Cheers
You can use TileProvider. The TileProvider provides the images that are used in the tile overlay. You should be able to save portion of map and create your own tileprovider and access tiles locally.

Make my own "Google Maps" using device location

Im on my final project in which I would like to build an android app especifically for the university context. Therefore I would like to use geolocation but for matters of detailed information (colors, shapes, buildings, etc) and gamefication I would like to draw my own map and the user should be able to see his position on this map. So I would have this drawn map and I would use the device's location service and transform the coordinates to a position on my map.
I'm kinda lost on this, didn't find much on the web. So I would apreciate if anyone could point me a direction or if anyone could tell me how hard would it be to implement. Would it be as simple as a function Point foo (double lat, double lon);?
Thanks in advance.
Drawing the whole map completely would be rather difficult and would involve loads of extra work, thus I would suggest you an alternative that would allow you to have your own drawings, on top of the already made Map.
You could for example use the groundoverlay, for items that you want to draw yourself. and then use the google maps under it to show the map, and to handle any positioning etc.

how to bound android google maps to a specific span, so when the user pan he can't exceed that span?

I want to bound google map in android around the UK,so the user can't pan the map to go outside uk.
There is definitely a way (or several ways) to do this for the maps web api (see links: http://econym.org.uk/gmap/range.htm and http://econym.org.uk/gmap/epoly.htm). However, I don't know of a built-in way to do this on android, so it may take some hackery.
You will likely have to rewrite part of the mapview class... I'd try either overwriting the getMaxZoomLevel (as suggested in the first link - simpler but may not work) or trying to somehow intercept all the map movement requests and checking them to see if they fall outside of certain coordinates (harder/may not even be possible - probably have to do something like call getLongituteSpan every time the map moves and maybe try moving the map back if the span is outside your desired area?)

Categories

Resources