2017년 4월 12일 수요일

Using latest Google Maps: navigation, distance calculation, markers, possible ?


Can anyone tell if it is possible to write an application in AI2, that could interact with Google Maps -- either the installed Android application (by passing Intents) or the web service, such that:

⦁ Programmatically (based on coordinates and description/label stored in a table), I can place "markers" on the map
⦁ Place a marker for the "current location" (fine or coarse)
⦁ Let user pick any 2 of the markers (POIs), to find of distance + travel-time between the 2 points ?
⦁ Let user pick a set of multiple POI's (markers), to find total distance ?
This morning, I tried few things, like trying to launch Google Maps, by passing an Intent, with the following type of geolocation URI's:

⦁ "geo:12.923,77.522"
⦁ "geo:12.923, 77.522"
⦁ "geo:0,0?q=12.923,77.522(Mark1)"
⦁ "geo:0,0?q=12.923, 77.522 (Mark1)"
⦁ "geo:0,0?q=avenue+road+bangalore"
However, none of them seemed to have any effect, i.e. the map after loading seems to be stuck at showing my present location only, and I cannot see any marker ("Mark1") or see any search results "avenue road bangalore". What might I be doing wrong ? I've tried this on a device running Android 4.2.2 and another one running Android 2.3.6 ! I just can't get maps working on Android Emulator.
Based on my reading of previous questions asked here, what I have understood is:

⦁ There seems to no way to show maps with markers, using Google Maps activity, but I need to use static-maps using the web-service method.
⦁ Distance calculation too needs to be done using the distance API using the web-service method.
⦁ I might have missed, but didn't see talk/examples pointing to usage of already installed Google Maps, by lanching an Activity and by passing intent parameters! Is it not the recommended way ?
Finally, if Google Maps is not installed on the device, when my app is installed, is there any way of checking this from within my application ? Also is there a way to prompt the user to install Google Maps ? Can the Google Maps installation be done automatically / silently, by my application (barring the permission check dialog) ?

--
Yes.

There are many ways to do what you want, here are some ideas:

1) In Google Maps, ordinarily you can only have two pins; your location and a destination.This is relatively easy to program with AI2  See the Where's my car tutorial.
2) You can use the Google Static Maps API to create a map with lots of pins.  This is more complicated but doable entirely with AI2 code.
Static Maps API - Google Developers
3) You can create a map using many hundreds of pins, annotate them too by using AI2 in conjunction with Google' Fusion Table and using the Maps option..  You create 
a simple Location database, post to it and let Fusion Table do the heavy lifting.  You then display the map on an Android device using either the WebViewer or the ActivityStarter.

Here is a more complicated way:  https://support.google.com/fusiontables/answer/2527132?hl=en  but your map could look like this:
Regarding:  "Based on my reading of previous questions asked here, what I have understood is:"

⦁ There seems to no way to show maps with markers, using Google Maps activity, but I need to use static-maps using the web-service method.
⦁ This is basically true.   On a basic google map, it is possible to easily display two points; your present location and a destination.  There are ways to get around this programming in Java but not AI 2 at the moment I believe.
⦁ Distance calculation too needs to be done using the distance API using the web-service method.
⦁ This is not true.  Distance can be calculate point to point (true distance not following roads) by using the Haversine algorithm ..this is a mathematical solution.  If you need the road distance, yes you need to use the Google API.   However, if you do use the Google distance api, you MUST also include a Google Map in your app.
⦁ I might have missed, but didn't see talk/examples pointing to usage of already installed Google Maps, by lanching an Activity and by passing intent parameters! Is it not the recommended way ?
⦁ Already installed maps?  What do you mean by that?     A developer can use ANY map as a base if he places the map image on a Canvas, then writes a routine to scale World coordinates to screen coordinates and vice versa.  See this thread:  https://groups.google.com/forum/#!searchin/mitappinventortest/world$20coordinates%7Csort:relevance/mitappinventortest/HfqU_V_wsCI/-WNUpRF226kJ  
Using the emulator:   you can get maps and post pins but you can not use the LocationSensor.  The emulator that comes with AI2 does not have a gps receiver.

Try some blocks.   If you have a specific question, post again, show an image of your blocks (jpg or png) and someone will provide specific advice.

--
Thanks a lot for the detailed answer.

--

댓글 없음:

댓글 쓰기