Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

[Q]about android studio and google maps

iel0000

Amateur
Advanced Member
Messages
132
Reaction score
3
Points
28
Power Stone
Reality Stone
Soul Stone
Time Stone
mga sir patulong naman kung panu paganahin ung pathfinding gamit ung google maps api sa android studio?
 
mga sir patulong naman kung panu paganahin ung pathfinding gamit ung google maps api sa android studio?

sa pagkakaalam ko x-axis y-axis lng yung gmap. search mo nlng pano magpalabas ng specific location using x-y kung nka save nmn sa db mo retrieve mo nlng.
 
mga sir patulong naman kung panu paganahin ung pathfinding gamit ung google maps api sa android studio?

0. Create a Google account
1. Login to https://console.developers.google.com
2. Select API Manager
3. Select Google Maps Android API
4. Click "Enable API"
5. Request for an API Key
6. In your Android project, you will create a class or function to handle sending a request to Google Maps API using your API Key. For example:
origin: 75 9th Ave, New York, NY
destination: MetLife Stadium Dr East Rutherford, NJ 07073
mode: driving
key: API_KEY

This is the formatted URL string going to be sent to Google Maps service.
"https://maps.googleapis.com/maps/api/directions/json?origin=75+9th+Ave+New+York,+NY&destination=MetLife+Stadium+1+MetLife+Stadium+Dr+East+Rutherford,+NJ+07073&key=YOUR_API_KEY"

7. Google Maps API will send back data in JSON format. Your app will have handle this response.

Code:
Response
{
   "geocoded_waypoints" : [
      {
         "geocoder_status" : "OK",
         "place_id" : "ChIJyYfhZ79ZwokRMtXcL6CYxkA",
         "types" : [ "premise" ]
      },
      {
         "geocoder_status" : "OK",
         "partial_match" : true,
         "place_id" : "ChIJ8YWMWnz4wokRCOVf1CcJCbY",
         "types" : [ "street_address" ]
      }
   ],
   "routes" : [
      {
         "bounds" : {
            "northeast" : {
               "lat" : 40.8171321,
               "lng" : -73.99449150000001
            },
            "southwest" : {
               "lat" : 40.7416627,
               "lng" : -74.0728354
            }
         },
         "copyrights" : "Map data ©2015 Google",
         "legs" : [
            {
               "distance" : {
                  "text" : "9.7 mi",
                  "value" : 15653
               },
               "duration" : {
                  "text" : "25 mins",
                  "value" : 1480
               },
               "end_address" : "1 MetLife Stadium Dr, East Rutherford, NJ 07073, USA",
               "end_location" : {
                  "lat" : 40.814505,
                  "lng" : -74.07272910000002
               },
               "start_address" : "75 Ninth Ave, New York, NY 10011, USA",
               "start_location" : {
                  "lat" : 40.7428759,
                  "lng" : -74.00584719999999
               },
               "steps" : [
                  {
                     "distance" : {
                        "text" : "440 ft",
                        "value" : 134
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 34
                     },
                     "end_location" : {
                        "lat" : 40.7422925,
                        "lng" : -74.004457
                     },
                     "html_instructions" : "Head \u003cb\u003esoutheast\u003c/b\u003e on \u003cb\u003eW 16th St\u003c/b\u003e toward \u003cb\u003eNinth Ave\u003c/b\u003e",
                     "polyline" : {
                        "points" : "_rtwFpgubMtBuG"
                     },
                     "start_location" : {
                        "lat" : 40.7428759,
                        "lng" : -74.00584719999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "49 ft",
                        "value" : 15
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 29
                     },
                     "end_location" : {
                        "lat" : 40.7421744,
                        "lng" : -74.0045361
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at the 1st cross street onto \u003cb\u003eNinth Ave\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "intwFz~tbMVN"
                     },
                     "start_location" : {
                        "lat" : 40.7422925,
                        "lng" : -74.004457
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "226 ft",
                        "value" : 69
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 24
                     },
                     "end_location" : {
                        "lat" : 40.7416627,
                        "lng" : -74.0049708
                     },
                     "html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e to stay on \u003cb\u003eNinth Ave\u003c/b\u003e",
                     "maneuver" : "turn-slight-right",
                     "polyline" : {
                        "points" : "qmtwFj_ubMDN@@?@JFXP`@VTN"
                     },
                     "start_location" : {
                        "lat" : 40.7421744,
                        "lng" : -74.0045361
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 mi",
                        "value" : 266
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 74
                     },
                     "end_location" : {
                        "lat" : 40.74282729999999,
                        "lng" : -74.00773459999999
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eW 15th St\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "kjtwF`bubMIVeBlFEN{A|EWr@"
                     },
                     "start_location" : {
                        "lat" : 40.7416627,
                        "lng" : -74.0049708
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "1.1 mi",
                        "value" : 1815
                     },
                     "duration" : {
                        "text" : "6 mins",
                        "value" : 349
                     },
                     "end_location" : {
                        "lat" : 40.7571135,
                        "lng" : -73.9973176
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at the 1st cross street onto \u003cb\u003e10th Ave\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "uqtwFhsubMo@c@oA{@iAw@A?EEc@YwBuAaAq@o@c@gBiAMIsBoAmA{@m@a@eCaBcCaB}BuA{ByAyB{A{ByAyByA_C{AYU}AaA{ByAUMCC]UcAs@eC_BeC_B{ByA{ByAyByA"
                     },
                     "start_location" : {
                        "lat" : 40.74282729999999,
                        "lng" : -74.00773459999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 mi",
                        "value" : 273
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 59
                     },
                     "end_location" : {
                        "lat" : 40.7559092,
                        "lng" : -73.99449150000001
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eW 38th St\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "}jwwFfrsbMzA}E@CNe@Tu@d@uAHYHU@AHWDM^iA"
                     },
                     "start_location" : {
                        "lat" : 40.7571135,
                        "lng" : -73.9973176
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "377 ft",
                        "value" : 115
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 38
                     },
                     "end_location" : {
                        "lat" : 40.7550018,
                        "lng" : -73.9951569
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at the 1st cross street onto \u003cb\u003eNinth Ave\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "mcwwFp`sbMtBtA~@n@"
                     },
                     "start_location" : {
                        "lat" : 40.7559092,
                        "lng" : -73.99449150000001
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.1 mi",
                        "value" : 226
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 39
                     },
                     "end_location" : {
                        "lat" : 40.7560886,
                        "lng" : -73.9950563
                     },
                     "html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e onto the \u003cb\u003eLincoln Tunnel\u003c/b\u003e ramp to \u003cb\u003eNew Jersey\u003c/b\u003e",
                     "polyline" : {
                        "points" : "w}vwFvdsbMJb@@D?D?D@D?DAB?D?DADADADYz@AFCBA@ABCBC@C@C?A?C?C?C?CACCECMUo@eAa@m@EIEECGEEGEEECEII"
                     },
                     "start_location" : {
                        "lat" : 40.7550018,
                        "lng" : -73.9951569
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "112 ft",
                        "value" : 34
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 6
                     },
                     "end_location" : {
                        "lat" : 40.7563822,
                        "lng" : -73.9949785
                     },
                     "html_instructions" : "Merge onto \u003cb\u003eNY-495 W\u003c/b\u003e",
                     "maneuver" : "merge",
                     "polyline" : {
                        "points" : "qdwwFbdsbMECECCAEAEAE?EAE?E?E?"
                     },
                     "start_location" : {
                        "lat" : 40.7560886,
                        "lng" : -73.9950563
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.9 mi",
                        "value" : 1453
                     },
                     "duration" : {
                        "text" : "2 mins",
                        "value" : 124
                     },
                     "end_location" : {
                        "lat" : 40.7631296,
                        "lng" : -74.00948579999999
                     },
                     "html_instructions" : "Keep \u003cb\u003eright\u003c/b\u003e at the fork to stay on \u003cb\u003eNY-495 W\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eEntering New Jersey\u003c/div\u003e",
                     "maneuver" : "fork-right",
                     "polyline" : {
                        "points" : "kfwwFrcsbMG?E?C@E@E@E@E@EBGBWNEBGDCBMLEDIJ?@IJADEFe@|@?BkBtDCBQ^ABABEFe@bAIRMb@KXGPWx@Wx@Oj@Ib@G\\Kl@CVALCJCL{BzGoA~DoA|DK`@ABUt@[~@CH_@hAcMz`@"
                     },
                     "start_location" : {
                        "lat" : 40.7563822,
                        "lng" : -73.9949785
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "2.8 mi",
                        "value" : 4516
                     },
                     "duration" : {
                        "text" : "5 mins",
                        "value" : 301
                     },
                     "end_location" : {
                        "lat" : 40.7767179,
                        "lng" : -74.042813
                     },
                     "html_instructions" : "Continue onto \u003cb\u003eNJ-495 W\u003c/b\u003e",
                     "polyline" : {
                        "points" : "qpxwFh~ubMsJpZsJpZeAbD[rAOt@Ij@E\\?@Cf@A\\?v@@j@@D?BB^D\\BJBL?B@FFVBFBHH\\P`@Tf@Z^X^jAx@HJFLFHJJp@h@`@Zf@`@VPZNb@P^Hl@TVBHDJFJDNJJFJJNJLJPLHHDDHDDBFDHBFBH@H?F?J?HAJAJCHCJEJEJGJGJIHIJKFMHMDKFODODOBQ@O@Q@S?QAO?QCOCQCOEQGOGMIOGMIIGIIGKIIGSISKm@Wg@Qg@Sk@Qi@Qi@Qi@Og@Me@Ke@Mo@Ki@Kg@Ge@Ie@G]C[CM?S?S@QBSDODODMFMDMHML_@^KHINIJGLIPITUl@cIxUMV?BSj@_@lAi@hBEH?@s@bCg@dBQp@?BKXSp@Yt@Wt@_@bAsBhFSf@CDiBzEi@rAYr@eArCSh@Qf@M^Od@Qj@_ErOIXGXIXIXGZK^K`@YbAI\\Sz@m@bCo@`CQp@Mh@Of@Sz@M`@Sx@g@dBIX"
                     },
                     "start_location" : {
                        "lat" : 40.7631296,
                        "lng" : -74.00948579999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.3 mi",
                        "value" : 435
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 21
                     },
                     "end_location" : {
                        "lat" : 40.7797406,
                        "lng" : -74.04597939999999
                     },
                     "html_instructions" : "Keep \u003cb\u003eright\u003c/b\u003e at the fork to continue on \u003cb\u003eNJ-3 W\u003c/b\u003e, follow signs for \u003cb\u003eNew Jersey 3 W\u003c/b\u003e/\u003cb\u003eGarden State Parkway\u003c/b\u003e/\u003cb\u003eSecaucus\u003c/b\u003e",
                     "maneuver" : "fork-right",
                     "polyline" : {
                        "points" : "oe{wFpn|bMc@fAEJIRIPKPKPMPOROPOPONOVIHy@|@oBnBUTURSPc@Ze@Zg@XaAb@"
                     },
                     "start_location" : {
                        "lat" : 40.7767179,
                        "lng" : -74.042813
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "2.2 mi",
                        "value" : 3560
                     },
                     "duration" : {
                        "text" : "2 mins",
                        "value" : 141
                     },
                     "end_location" : {
                        "lat" : 40.8041562,
                        "lng" : -74.0717843
                     },
                     "html_instructions" : "Keep \u003cb\u003eleft\u003c/b\u003e to stay on \u003cb\u003eNJ-3 W\u003c/b\u003e, follow signs for \u003cb\u003eNew Jersey 3 W\u003c/b\u003e/\u003cb\u003eClifton\u003c/b\u003e",
                     "maneuver" : "keep-left",
                     "polyline" : {
                        "points" : "kx{wFjb}bMMJGDEBEBIDeA`@m@R{@VyA`@aB\\qAXiB`@uCl@A?A?QDs@NSFuAXwBf@{@Za@Nm@T_@NYLi@VmAl@gAp@m@`@}@l@QPA@IDA@[XA@_@Ze@`@ONA@i@h@STu@v@eApA}@pAq@bAwAzBgC~DaBhCs@lAq@|@YZo@hA{@pA_A~AsArB{@rAuAvBq@jAUZABA@qFjIe@t@mDpFOVcCvDgElGQVkC|D?@yBhDcDbFy@lAsCfEyGzJ{BdDUZsAzB"
                     },
                     "start_location" : {
                        "lat" : 40.7797406,
                        "lng" : -74.04597939999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 mi",
                        "value" : 249
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 13
                     },
                     "end_location" : {
                        "lat" : 40.8062905,
                        "lng" : -74.07245929999999
                     },
                     "html_instructions" : "Take the \u003cb\u003eNJ-120 N\u003c/b\u003e exit toward \u003cb\u003eE Rutherford\u003c/b\u003e",
                     "maneuver" : "ramp-right",
                     "polyline" : {
                        "points" : "_q`xFrcbcMSBA?CBIFOLi@^SJSJOFQFSDODUD]Ba@@g@@_BF"
                     },
                     "start_location" : {
                        "lat" : 40.8041562,
                        "lng" : -74.0717843
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "410 ft",
                        "value" : 125
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 6
                     },
                     "end_location" : {
                        "lat" : 40.807415,
                        "lng" : -74.07250909999999
                     },
                     "html_instructions" : "Keep \u003cb\u003eleft\u003c/b\u003e, follow signs for \u003cb\u003eState Route 503 N\u003c/b\u003e/\u003cb\u003eNew Jersey 120 N\u003c/b\u003e/\u003cb\u003eWashington Avenue\u003c/b\u003e/\u003cb\u003eMoonachie\u003c/b\u003e/\u003cb\u003ePaterson Plank Road\u003c/b\u003e",
                     "maneuver" : "keep-left",
                     "polyline" : {
                        "points" : "i~`xFzgbcMaFH"
                     },
                     "start_location" : {
                        "lat" : 40.8062905,
                        "lng" : -74.07245929999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.5 mi",
                        "value" : 869
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 38
                     },
                     "end_location" : {
                        "lat" : 40.8145647,
                        "lng" : -74.06878929999999
                     },

                    ...... // edit: etc etc string is too long to post


         },
         "summary" : "NJ-495 W and NJ-3 W",
         "warnings" : [],
         "waypoint_order" : []
      }
   ],
   "status" : "OK"
}
 
0. Create a Google account
1. Login to https://console.developers.google.com
2. Select API Manager
3. Select Google Maps Android API
4. Click "Enable API"
5. Request for an API Key
6. In your Android project, you will create a class or function to handle sending a request to Google Maps API using your API Key. For example:
origin: 75 9th Ave, New York, NY
destination: MetLife Stadium Dr East Rutherford, NJ 07073
mode: driving
key: API_KEY

This is the formatted URL string going to be sent to Google Maps service.
"https://maps.googleapis.com/maps/api/directions/json?origin=75+9th+Ave+New+York,+NY&destination=MetLife+Stadium+1+MetLife+Stadium+Dr+East+Rutherford,+NJ+07073&key=YOUR_API_KEY"

7. Google Maps API will send back data in JSON format. Your app will have handle this response.

Code:
Response
{
   "geocoded_waypoints" : [
      {
         "geocoder_status" : "OK",
         "place_id" : "ChIJyYfhZ79ZwokRMtXcL6CYxkA",
         "types" : [ "premise" ]
      },
      {
         "geocoder_status" : "OK",
         "partial_match" : true,
         "place_id" : "ChIJ8YWMWnz4wokRCOVf1CcJCbY",
         "types" : [ "street_address" ]
      }
   ],
   "routes" : [
      {
         "bounds" : {
            "northeast" : {
               "lat" : 40.8171321,
               "lng" : -73.99449150000001
            },
            "southwest" : {
               "lat" : 40.7416627,
               "lng" : -74.0728354
            }
         },
         "copyrights" : "Map data ©2015 Google",
         "legs" : [
            {
               "distance" : {
                  "text" : "9.7 mi",
                  "value" : 15653
               },
               "duration" : {
                  "text" : "25 mins",
                  "value" : 1480
               },
               "end_address" : "1 MetLife Stadium Dr, East Rutherford, NJ 07073, USA",
               "end_location" : {
                  "lat" : 40.814505,
                  "lng" : -74.07272910000002
               },
               "start_address" : "75 Ninth Ave, New York, NY 10011, USA",
               "start_location" : {
                  "lat" : 40.7428759,
                  "lng" : -74.00584719999999
               },
               "steps" : [
                  {
                     "distance" : {
                        "text" : "440 ft",
                        "value" : 134
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 34
                     },
                     "end_location" : {
                        "lat" : 40.7422925,
                        "lng" : -74.004457
                     },
                     "html_instructions" : "Head \u003cb\u003esoutheast\u003c/b\u003e on \u003cb\u003eW 16th St\u003c/b\u003e toward \u003cb\u003eNinth Ave\u003c/b\u003e",
                     "polyline" : {
                        "points" : "_rtwFpgubMtBuG"
                     },
                     "start_location" : {
                        "lat" : 40.7428759,
                        "lng" : -74.00584719999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "49 ft",
                        "value" : 15
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 29
                     },
                     "end_location" : {
                        "lat" : 40.7421744,
                        "lng" : -74.0045361
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at the 1st cross street onto \u003cb\u003eNinth Ave\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "intwFz~tbMVN"
                     },
                     "start_location" : {
                        "lat" : 40.7422925,
                        "lng" : -74.004457
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "226 ft",
                        "value" : 69
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 24
                     },
                     "end_location" : {
                        "lat" : 40.7416627,
                        "lng" : -74.0049708
                     },
                     "html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e to stay on \u003cb\u003eNinth Ave\u003c/b\u003e",
                     "maneuver" : "turn-slight-right",
                     "polyline" : {
                        "points" : "qmtwFj_ubMDN@@?@JFXP`@VTN"
                     },
                     "start_location" : {
                        "lat" : 40.7421744,
                        "lng" : -74.0045361
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 mi",
                        "value" : 266
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 74
                     },
                     "end_location" : {
                        "lat" : 40.74282729999999,
                        "lng" : -74.00773459999999
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eW 15th St\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "kjtwF`bubMIVeBlFEN{A|EWr@"
                     },
                     "start_location" : {
                        "lat" : 40.7416627,
                        "lng" : -74.0049708
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "1.1 mi",
                        "value" : 1815
                     },
                     "duration" : {
                        "text" : "6 mins",
                        "value" : 349
                     },
                     "end_location" : {
                        "lat" : 40.7571135,
                        "lng" : -73.9973176
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at the 1st cross street onto \u003cb\u003e10th Ave\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "uqtwFhsubMo@c@oA{@iAw@A?EEc@YwBuAaAq@o@c@gBiAMIsBoAmA{@m@a@eCaBcCaB}BuA{ByAyB{A{ByAyByA_C{AYU}AaA{ByAUMCC]UcAs@eC_BeC_B{ByA{ByAyByA"
                     },
                     "start_location" : {
                        "lat" : 40.74282729999999,
                        "lng" : -74.00773459999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 mi",
                        "value" : 273
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 59
                     },
                     "end_location" : {
                        "lat" : 40.7559092,
                        "lng" : -73.99449150000001
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eW 38th St\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "}jwwFfrsbMzA}E@CNe@Tu@d@uAHYHU@AHWDM^iA"
                     },
                     "start_location" : {
                        "lat" : 40.7571135,
                        "lng" : -73.9973176
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "377 ft",
                        "value" : 115
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 38
                     },
                     "end_location" : {
                        "lat" : 40.7550018,
                        "lng" : -73.9951569
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at the 1st cross street onto \u003cb\u003eNinth Ave\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "mcwwFp`sbMtBtA~@n@"
                     },
                     "start_location" : {
                        "lat" : 40.7559092,
                        "lng" : -73.99449150000001
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.1 mi",
                        "value" : 226
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 39
                     },
                     "end_location" : {
                        "lat" : 40.7560886,
                        "lng" : -73.9950563
                     },
                     "html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e onto the \u003cb\u003eLincoln Tunnel\u003c/b\u003e ramp to \u003cb\u003eNew Jersey\u003c/b\u003e",
                     "polyline" : {
                        "points" : "w}vwFvdsbMJb@@D?D?D@D?DAB?D?DADADADYz@AFCBA@ABCBC@C@C?A?C?C?C?CACCECMUo@eAa@m@EIEECGEEGEEECEII"
                     },
                     "start_location" : {
                        "lat" : 40.7550018,
                        "lng" : -73.9951569
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "112 ft",
                        "value" : 34
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 6
                     },
                     "end_location" : {
                        "lat" : 40.7563822,
                        "lng" : -73.9949785
                     },
                     "html_instructions" : "Merge onto \u003cb\u003eNY-495 W\u003c/b\u003e",
                     "maneuver" : "merge",
                     "polyline" : {
                        "points" : "qdwwFbdsbMECECCAEAEAE?EAE?E?E?"
                     },
                     "start_location" : {
                        "lat" : 40.7560886,
                        "lng" : -73.9950563
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.9 mi",
                        "value" : 1453
                     },
                     "duration" : {
                        "text" : "2 mins",
                        "value" : 124
                     },
                     "end_location" : {
                        "lat" : 40.7631296,
                        "lng" : -74.00948579999999
                     },
                     "html_instructions" : "Keep \u003cb\u003eright\u003c/b\u003e at the fork to stay on \u003cb\u003eNY-495 W\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eEntering New Jersey\u003c/div\u003e",
                     "maneuver" : "fork-right",
                     "polyline" : {
                        "points" : "kfwwFrcsbMG?E?C@E@E@E@E@EBGBWNEBGDCBMLEDIJ?@IJADEFe@|@?BkBtDCBQ^ABABEFe@bAIRMb@KXGPWx@Wx@Oj@Ib@G\\Kl@CVALCJCL{BzGoA~DoA|DK`@ABUt@[~@CH_@hAcMz`@"
                     },
                     "start_location" : {
                        "lat" : 40.7563822,
                        "lng" : -73.9949785
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "2.8 mi",
                        "value" : 4516
                     },
                     "duration" : {
                        "text" : "5 mins",
                        "value" : 301
                     },
                     "end_location" : {
                        "lat" : 40.7767179,
                        "lng" : -74.042813
                     },
                     "html_instructions" : "Continue onto \u003cb\u003eNJ-495 W\u003c/b\u003e",
                     "polyline" : {
                        "points" : "qpxwFh~ubMsJpZsJpZeAbD[rAOt@Ij@E\\?@Cf@A\\?v@@j@@D?BB^D\\BJBL?B@FFVBFBHH\\P`@Tf@Z^X^jAx@HJFLFHJJp@h@`@Zf@`@VPZNb@P^Hl@TVBHDJFJDNJJFJJNJLJPLHHDDHDDBFDHBFBH@H?F?J?HAJAJCHCJEJEJGJGJIHIJKFMHMDKFODODOBQ@O@Q@S?QAO?QCOCQCOEQGOGMIOGMIIGIIGKIIGSISKm@Wg@Qg@Sk@Qi@Qi@Qi@Og@Me@Ke@Mo@Ki@Kg@Ge@Ie@G]C[CM?S?S@QBSDODODMFMDMHML_@^KHINIJGLIPITUl@cIxUMV?BSj@_@lAi@hBEH?@s@bCg@dBQp@?BKXSp@Yt@Wt@_@bAsBhFSf@CDiBzEi@rAYr@eArCSh@Qf@M^Od@Qj@_ErOIXGXIXIXGZK^K`@YbAI\\Sz@m@bCo@`CQp@Mh@Of@Sz@M`@Sx@g@dBIX"
                     },
                     "start_location" : {
                        "lat" : 40.7631296,
                        "lng" : -74.00948579999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.3 mi",
                        "value" : 435
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 21
                     },
                     "end_location" : {
                        "lat" : 40.7797406,
                        "lng" : -74.04597939999999
                     },
                     "html_instructions" : "Keep \u003cb\u003eright\u003c/b\u003e at the fork to continue on \u003cb\u003eNJ-3 W\u003c/b\u003e, follow signs for \u003cb\u003eNew Jersey 3 W\u003c/b\u003e/\u003cb\u003eGarden State Parkway\u003c/b\u003e/\u003cb\u003eSecaucus\u003c/b\u003e",
                     "maneuver" : "fork-right",
                     "polyline" : {
                        "points" : "oe{wFpn|bMc@fAEJIRIPKPKPMPOROPOPONOVIHy@|@oBnBUTURSPc@Ze@Zg@XaAb@"
                     },
                     "start_location" : {
                        "lat" : 40.7767179,
                        "lng" : -74.042813
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "2.2 mi",
                        "value" : 3560
                     },
                     "duration" : {
                        "text" : "2 mins",
                        "value" : 141
                     },
                     "end_location" : {
                        "lat" : 40.8041562,
                        "lng" : -74.0717843
                     },
                     "html_instructions" : "Keep \u003cb\u003eleft\u003c/b\u003e to stay on \u003cb\u003eNJ-3 W\u003c/b\u003e, follow signs for \u003cb\u003eNew Jersey 3 W\u003c/b\u003e/\u003cb\u003eClifton\u003c/b\u003e",
                     "maneuver" : "keep-left",
                     "polyline" : {
                        "points" : "kx{wFjb}bMMJGDEBEBIDeA`@m@R{@VyA`@aB\\qAXiB`@uCl@A?A?QDs@NSFuAXwBf@{@Za@Nm@T_@NYLi@VmAl@gAp@m@`@}@l@QPA@IDA@[XA@_@Ze@`@ONA@i@h@STu@v@eApA}@pAq@bAwAzBgC~DaBhCs@lAq@|@YZo@hA{@pA_A~AsArB{@rAuAvBq@jAUZABA@qFjIe@t@mDpFOVcCvDgElGQVkC|D?@yBhDcDbFy@lAsCfEyGzJ{BdDUZsAzB"
                     },
                     "start_location" : {
                        "lat" : 40.7797406,
                        "lng" : -74.04597939999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 mi",
                        "value" : 249
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 13
                     },
                     "end_location" : {
                        "lat" : 40.8062905,
                        "lng" : -74.07245929999999
                     },
                     "html_instructions" : "Take the \u003cb\u003eNJ-120 N\u003c/b\u003e exit toward \u003cb\u003eE Rutherford\u003c/b\u003e",
                     "maneuver" : "ramp-right",
                     "polyline" : {
                        "points" : "_q`xFrcbcMSBA?CBIFOLi@^SJSJOFQFSDODUD]Ba@@g@@_BF"
                     },
                     "start_location" : {
                        "lat" : 40.8041562,
                        "lng" : -74.0717843
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "410 ft",
                        "value" : 125
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 6
                     },
                     "end_location" : {
                        "lat" : 40.807415,
                        "lng" : -74.07250909999999
                     },
                     "html_instructions" : "Keep \u003cb\u003eleft\u003c/b\u003e, follow signs for \u003cb\u003eState Route 503 N\u003c/b\u003e/\u003cb\u003eNew Jersey 120 N\u003c/b\u003e/\u003cb\u003eWashington Avenue\u003c/b\u003e/\u003cb\u003eMoonachie\u003c/b\u003e/\u003cb\u003ePaterson Plank Road\u003c/b\u003e",
                     "maneuver" : "keep-left",
                     "polyline" : {
                        "points" : "i~`xFzgbcMaFH"
                     },
                     "start_location" : {
                        "lat" : 40.8062905,
                        "lng" : -74.07245929999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.5 mi",
                        "value" : 869
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 38
                     },
                     "end_location" : {
                        "lat" : 40.8145647,
                        "lng" : -74.06878929999999
                     },

                    ...... // edit: etc etc string is too long to post


         },
         "summary" : "NJ-495 W and NJ-3 W",
         "warnings" : [],
         "waypoint_order" : []
      }
   ],
   "status" : "OK"
}

Panu pag ang starting position eh ung location kung nasan ako?
 
di ko pa mgawa sir

- - - Updated - - -



lahat ng nakita kong sample about dun sa http response puro pang web panu sya implement sa android @.@

Google Maps API is a Web service. You need to send a GET request in your Android onCreate() method or any method in your app where you feel it's appropriate. You build this URL using StringBuilder class. You basically build a string with the location origin and destination. For a more accurate response from Google Map API, both locations can be GPS coordinates (longitute and latitude).

Below is an example of this URL string.

https://maps.googleapis.com/maps/api/directions/json?origin=75+9th+Ave+New+York,+NY&destination=MetLife+Stadium+1+MetLife+Stadium+Dr+East+Rutherford ,+NJ+07073&key=YOUR_API_KEY"

Somewhere in your code, you create a URLConnection.

Say for instance the URL string above is assigned to a String variable "theURL".
You then connect to the Maps API like so:

Code:
URL url = new URL(theURL);
URLConnection urlConnection = url.openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
StringBuilder content = new StringBuilder();
String line;

while ((line = br.readLine()) != null) 
{
   content.append(line + "\n");
}

br.close();

If the request is successful, content.toString() will have a list of locations in JSON format. You need to know the structure of this JSON string so you can process it properly, and how you process it is dependent on its structure (Look at the example response I posted above).

You usually start processing like this:
JSONObject object = new JSONObject(json);
JSONArray array = object.getJSONArray("Response");

You loop through and get the information you need such as "start_location", "end_location", "distance", "duration", etc.
 
Back
Top Bottom