2015-04-30 71 views
-1

我想做一個Android應用程序,它搜索(在谷歌地圖或其他地圖服務)兩點之間的步行路線,並開始導航,但不是顯示地圖,我想顯示一個大方向的箭頭。這可以做到嗎?是否可以在沒有地圖的情況下顯示Google地圖導航?

我有java的經驗,但不是在Android開發中,目前我正在開發Android開發課程,並且我需要知道如果必須重新構造我的應用程序或重新設置,這是否可以完成。

回答

0

你真的想使用GooglePlacesAPI,而不是谷歌地圖: https://developers.google.com/places/

這使您可以格式化HTML地址,如: https://maps.googleapis.com/maps/api/directions/json?key=APIKEY&origin=42.2912,-83.7161&destination=42.293932,-83.715527&mode=walking&departure_time=now

然後將返回的是這樣的一個JSON字符串:

{ 
    "routes" : [ 
     { 
     "bounds" : { 
      "northeast" : { 
       "lat" : 42.2939666, 
       "lng" : -83.7155274 
      }, 
      "southwest" : { 
       "lat" : 42.29159749999999, 
       "lng" : -83.7162498 
      } 
     }, 
     "copyrights" : "Map data ©2015 Google", 
     "legs" : [ 
      { 
       "distance" : { 
        "text" : "0.2 mi", 
        "value" : 322 
       }, 
       "duration" : { 
        "text" : "5 mins", 
        "value" : 290 
       }, 
       "end_address" : "University of Michigan - North Campus, 2086-2180 Hayward Street, Ann Arbor, MI 48109, USA", 
       "end_location" : { 
        "lat" : 42.2939666, 
        "lng" : -83.7155274 
       }, 
       "start_address" : "University of Michigan - North Campus, 1230 Murfin Avenue, Ann Arbor, MI 48109, USA", 
       "start_location" : { 
        "lat" : 42.29159749999999, 
        "lng" : -83.7162498 
       }, 
       "steps" : [ 
        { 
        "distance" : { 
         "text" : "0.1 mi", 
         "value" : 234 
        }, 
        "duration" : { 
         "text" : "4 mins", 
         "value" : 217 
        }, 
        "end_location" : { 
         "lat" : 42.2935727, 
         "lng" : -83.7158445 
        }, 
        "html_instructions" : "Head \u003cb\u003enortheast\u003c/b\u003e", 
        "polyline" : { 
         "points" : "oacaGpy}}[email protected]@[email protected]@eAC" 
        }, 
        "start_location" : { 
         "lat" : 42.29159749999999, 
         "lng" : -83.7162498 
        }, 
        "travel_mode" : "WALKING" 
        }, 
        { 
        "distance" : { 
         "text" : "30 ft", 
         "value" : 9 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 10 
        }, 
        "end_location" : { 
         "lat" : 42.2935718, 
         "lng" : -83.7159588 
        }, 
        "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e toward \u003cb\u003eHayward St\u003c/b\u003e", 
        "maneuver" : "turn-left", 
        "polyline" : { 
         "points" : "ymcaG~v}}N?V" 
        }, 
        "start_location" : { 
         "lat" : 42.2935727, 
         "lng" : -83.7158445 
        }, 
        "travel_mode" : "WALKING" 
        }, 
        { 
        "distance" : { 
         "text" : "141 ft", 
         "value" : 43 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 38 
        }, 
        "end_location" : { 
         "lat" : 42.2939604, 
         "lng" : -83.7159652 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e toward \u003cb\u003eHayward St\u003c/b\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "ymcaGvw}}[email protected]" 
        }, 
        "start_location" : { 
         "lat" : 42.2935718, 
         "lng" : -83.7159588 
        }, 
        "travel_mode" : "WALKING" 
        }, 
        { 
        "distance" : { 
         "text" : "118 ft", 
         "value" : 36 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 25 
        }, 
        "end_location" : { 
         "lat" : 42.2939666, 
         "lng" : -83.7155274 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eHayward St\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "gpcaGxw}}NAgA?O" 
        }, 
        "start_location" : { 
         "lat" : 42.2939604, 
         "lng" : -83.7159652 
        }, 
        "travel_mode" : "WALKING" 
        } 
       ], 
       "via_waypoint" : [] 
      } 
     ], 
     "overview_polyline" : { 
      "points" : "oacaGpy}}[email protected][email protected]@[email protected]?O" 
     }, 
     "summary" : "Hayward St", 
     "warnings" : [ 
      "Walking directions are in beta. Use caution – This route may be missing sidewalks or pedestrian paths." 
     ], 
     "waypoint_order" : [] 
     } 
    ], 
    "status" : "OK" 
} 

在這一點上,做任何你想做的事情(AKA與加速度計和GPS結合起來),可在屏幕上做任何自定義圖像

相關問題