我想做一个Android应用程序搜索(在谷歌地图或其他地图服务中)两个点之间的步行路线并开始导航,但不是显示地图我想显示一个方向的大箭头。可以这样做吗?
我在java方面有经验,但在Android开发方面没有,目前我正在开发Android开发课程,如果我必须重新构建我的应用程序或requeriments,我需要知道是否可以这样做。
答案 0 :(得分:0)
您实际上想要使用GooglePlacesAPI而不是Google地图: 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}}N_AqAw@CgAEs@?MDMDs@@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}}NmA@"
},
"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}}N_AqA_CIs@?MDMDs@@eAC?VmA@AgA?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结合使用)在屏幕上进行任何自定义图像