如何更改谷歌地图JSON,以便不下载冗余内容并加快低带宽网络上的应用程序。例如,应用程序不支持导航,因此JSON中不需要步骤,也可以下载这些步骤,并使应用程序在低带宽网络上变慢。
例如: -
源地图和目的地之间的Google Map JSON: -
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJbZ--gzESrjsRsmxa_tmvhlI",
"types" : [ "route" ]
},
{
"geocoder_status" : "OK",
"place_id" : "Elk4NjksIDEydGggTWFpbiBSb2FkLCBLb3JhbWFuZ2FsYSAzIEJsb2NrLCBLb3JhbWFuZ2FsYSwgQmVuZ2FsdXJ1LCBLYXJuYXRha2EgNTYwMDM0LCBJbmRpYQ",
"types" : [ "street_address" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 12.959155,
"lng" : 77.7091214
},
"southwest" : {
"lat" : 12.9206335,
"lng" : 77.6264824
}
},
"copyrights" : "Map data ©2015 Google",
"legs" : [
{
"distance" : {
"text" : "12.5 km",
"value" : 12510
},
"duration" : {
"text" : "29 mins",
"value" : 1750
},
"end_address" : "869, 12th Main Road, Koramangala 3 Block, Koramangala, Bengaluru, Karnataka 560034, India",
"end_location" : {
"lat" : 12.9280212,
"lng" : 77.6267905
},
"start_address" : "PFS Driveway, Lakshminarayana Pura, AECS Layout, Marathahalli, Bengaluru, Karnataka 560037, India",
"start_location" : {
"lat" : 12.959155,
"lng" : 77.70615509999999
},
"steps" : [
{
"distance" : {
"text" : "0.3 km",
"value" : 283
},
"duration" : {
"text" : "1 min",
"value" : 68
},
"end_location" : {
"lat" : 12.9569421,
"lng" : 77.70609429999999
},
"html_instructions" : "Head \u003cb\u003esouth\u003c/b\u003e on \u003cb\u003ePFS Driveway\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eRestricted usage road\u003c/div\u003e",
"polyline" : {
"points" : "wabnAo~gyMzK_AH?D@DD@F?F@N?D@J@D?F@D"
},
"start_location" : {
"lat" : 12.959155,
"lng" : 77.70615509999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "26 m",
"value" : 26
},
"duration" : {
"text" : "1 min",
"value" : 6
},
"end_location" : {
"lat" : 12.9567068,
"lng" : 77.70613229999999
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e to stay on \u003cb\u003ePFS Driveway\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eRestricted usage road\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "{sanAa~gyMl@G"
},
"start_location" : {
"lat" : 12.9569421,
"lng" : 77.70609429999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.1 km",
"value" : 138
},
"duration" : {
"text" : "1 min",
"value" : 59
},
"end_location" : {
"lat" : 12.9568247,
"lng" : 77.70486409999999
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eMarathalli Bridge Service Rd\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "mranAi~gyMC^Q|E"
},
"start_location" : {
"lat" : 12.9567068,
"lng" : 77.70613229999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "36 m",
"value" : 36
},
"duration" : {
"text" : "1 min",
"value" : 8
},
"end_location" : {
"lat" : 12.9565042,
"lng" : 77.70486959999999
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eMunnekollal Main Rd\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "csanAkvgyM~@A"
},
"start_location" : {
"lat" : 12.9568247,
"lng" : 77.70486409999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.5 km",
"value" : 482
},
"duration" : {
"text" : "1 min",
"value" : 83
},
"end_location" : {
"lat" : 12.9563276,
"lng" : 77.7091214
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eMarathalli Bridge Service Rd\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "cqanAmvgyMPkGFuCV_GHeB?K@CDWD]g@C"
},
"start_location" : {
"lat" : 12.9565042,
"lng" : 77.70486959999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.8 km",
"value" : 838
},
"duration" : {
"text" : "2 mins",
"value" : 142
},
"end_location" : {
"lat" : 12.956896,
"lng" : 77.70141439999999
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eMarathalli Bridge/Old Airport Rd/Varthur Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinue to follow Old Airport Rd/Varthur Rd\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "apanA_qhyMs@nVE|A?@AB?@ErBInAG~BMlCA^ARC^CR?B?@?r@AXA`@"
},
"start_location" : {
"lat" : 12.9563276,
"lng" : 77.7091214
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.4 km",
"value" : 411
},
"duration" : {
"text" : "1 min",
"value" : 62
},
"end_location" : {
"lat" : 12.9533531,
"lng" : 77.7003715
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e toward \u003cb\u003eNH7\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "ssanAy`gyMRJHDFDvBb@xBf@ZHpK`B"
},
"start_location" : {
"lat" : 12.956896,
"lng" : 77.70141439999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "31 m",
"value" : 31
},
"duration" : {
"text" : "1 min",
"value" : 23
},
"end_location" : {
"lat" : 12.9531397,
"lng" : 77.7001892
},
"html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e toward \u003cb\u003eNH7\u003c/b\u003e",
"maneuver" : "turn-slight-right",
"polyline" : {
"points" : "m}`nAizfyMHF^Z"
},
"start_location" : {
"lat" : 12.9533531,
"lng" : 77.7003715
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "3.8 km",
"value" : 3796
},
"duration" : {
"text" : "6 mins",
"value" : 373
},
"end_location" : {
"lat" : 12.9274228,
"lng" : 77.6798031
},
"html_instructions" : "Slight \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eNH7\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by VIMS Super Specialty Hospital (on the left in 550 m)\u003c/div\u003e",
"maneuver" : "turn-slight-left",
"polyline" : {
"points" : "c|`nAeyfyM`Ft@lBRzFl@|Fj@x@JzATn@J`AR~A`@fB`@dB`@j@Ph@PhKdCr@R^HVJZJ`@Nb@RdAh@bAf@x@`@r@X\\N`@PtAp@pBdA~@f@`Ah@lAx@`Av@n@n@xB|BfBpBb@f@fBtBtDdE`AdAbCpC`CjCtC`DpIlJxF|G^h@PTNXXf@\\r@Th@p@dBl@~AjA~CxA~Dx@zBVp@p@hBr@hBJR"
},
"start_location" : {
"lat" : 12.9531397,
"lng" : 77.7001892
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "3.0 km",
"value" : 3010
},
"duration" : {
"text" : "5 mins",
"value" : 270
},
"end_location" : {
"lat" : 12.9237183,
"lng" : 77.6540827
},
"html_instructions" : "Keep \u003cb\u003eleft\u003c/b\u003e to stay on \u003cb\u003eNH7\u003c/b\u003e",
"maneuver" : "keep-left",
"polyline" : {
"points" : "k{{mAwybyMRf@rBxFbD|I^~@\\~@~C`I^jAX|@Vv@zAnEfBlF|@~BvAbEtBfFZ|@hFbNT~@@J?J@J@J?L?JAL?LAJAJCLALEREXe@hC_AnEMr@Kn@a@xC]bCa@zBk@lCaA|D_AfD_AvDc@fBYrAMx@OlAe@vD"
},
"start_location" : {
"lat" : 12.9274228,
"lng" : 77.6798031
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.4 km",
"value" : 438
},
"duration" : {
"text" : "1 min",
"value" : 66
},
"end_location" : {
"lat" : 12.924442,
"lng" : 77.6501267
},
"html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e at \u003cb\u003eAgra Exit\u003c/b\u003e toward \u003cb\u003eSarjapur Main Rd\u003c/b\u003e",
"maneuver" : "turn-slight-right",
"polyline" : {
"points" : "gd{mA_y}xMQb@Mv@QtAu@rGYjCCXCXA\\AXAP?P?r@"
},
"start_location" : {
"lat" : 12.9237183,
"lng" : 77.6540827
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "1.8 km",
"value" : 1816
},
"duration" : {
"text" : "5 mins",
"value" : 304
},
"end_location" : {
"lat" : 12.9248137,
"lng" : 77.63406830000001
},
"html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eSarjapur Main Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Karthikshekar Hospital (on the left in 1.3 km)\u003c/div\u003e",
"maneuver" : "turn-slight-right",
"polyline" : {
"points" : "wh{mAi`}xMEDCDEFCFA@I`@I\\?@AV?R@|@?JD~@Dx@Bl@DtB@TDx@Dd@?NDz@?P@L?V?l@?nC@^@\\@P@H@DFTx@jD\\jBf@jC`@fCVjADVDP@H?H?JAH?FADADADCFCHmArEEL_BpFCHA@ADGJIRKPW`@[f@S^Wl@KXEJCJA@AHCFCHAHERCNANAPAD?F?F@PBVNtAPxB`@lELbA"
},
"start_location" : {
"lat" : 12.924442,
"lng" : 77.6501267
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "77 m",
"value" : 77
},
"duration" : {
"text" : "1 min",
"value" : 44
},
"end_location" : {
"lat" : 12.9250061,
"lng" : 77.6335821
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003e80 Feet Main Rd/Mahatyagi Laksmidevi Rd\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "ak{mA}{yxMFfA@PSB]B"
},
"start_location" : {
"lat" : 12.9248137,
"lng" : 77.63406830000001
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.6 km",
"value" : 579
},
"duration" : {
"text" : "2 mins",
"value" : 101
},
"end_location" : {
"lat" : 12.9245984,
"lng" : 77.62833669999999
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003e1st Cross Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Sandeepani (on the right)\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "il{mA{xyxMDb@VdCL~APzBz@hILzBCh@Gl@i@rB"
},
"start_location" : {
"lat" : 12.9250061,
"lng" : 77.6335821
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.2 km",
"value" : 174
},
"duration" : {
"text" : "1 min",
"value" : 37
},
"end_location" : {
"lat" : 12.9261219,
"lng" : 77.628711
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003e8th Main Rd\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "wi{mAcxxxM_Dk@uBYYC"
},
"start_location" : {
"lat" : 12.9245984,
"lng" : 77.62833669999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.3 km",
"value" : 264
},
"duration" : {
"text" : "1 min",
"value" : 58
},
"end_location" : {
"lat" : 12.9270734,
"lng" : 77.6264824
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003e3rd Cross Rd\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "gs{mAmzxxMe@zAe@xA}@lCs@xB"
},
"start_location" : {
"lat" : 12.9261219,
"lng" : 77.628711
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.1 km",
"value" : 111
},
"duration" : {
"text" : "1 min",
"value" : 46
},
"end_location" : {
"lat" : 12.9280212,
"lng" : 77.6267905
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003e12th Main Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by the park (on the right)\u003c/div\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "ey{mAolxxM}D}@"
},
"start_location" : {
"lat" : 12.9270734,
"lng" : 77.6264824
},
"travel_mode" : "DRIVING"
}
],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "wabnAo~gyMdL_AJFBd@BX@Dl@GU|F~@APkG^uKHqBF[D]g@Cy@lYAFErBInAUlGKfBArAA`@RJPJpFjAlLjBh@b@`Ft@lBRxNxAtC`@pB^fEbApCr@rLvCfCt@dAb@hCpAlD|AfEvB`CpAlAx@`Av@hDlDhLtM|MdOpIlJxF|Gp@~@h@`Ar@|AdGdPvD`K^z@vGvQ|@~B~C`I^jAp@tBbE|LtCbIpCdHhFbNT~@@VBp@Er@QhAeBxIYbB_A|Ga@zBk@lCaA|D_AfDcB~Gg@lCu@dGQb@Mv@gAhJ]dDEv@CpBSZUbA?tBJxBHbDLdCFrB?|DB|@BZHZvAvGhArGd@~BAf@IXwD|MO\\iAnBk@lAQd@K^Ov@En@Dp@pA`NHxAq@F|@dKz@hILzBKvAi@rB_Dk@oC]}D|L}D}@"
},
"summary" : "NH7",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}
某些应用程序所需的JSON: -
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJbZ--gzESrjsRsmxa_tmvhlI",
"types" : [ "route" ]
},
{
"geocoder_status" : "OK",
"place_id" : "Elk4NjksIDEydGggTWFpbiBSb2FkLCBLb3JhbWFuZ2FsYSAzIEJsb2NrLCBLb3JhbWFuZ2FsYSwgQmVuZ2FsdXJ1LCBLYXJuYXRha2EgNTYwMDM0LCBJbmRpYQ",
"types" : [ "street_address" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 12.959155,
"lng" : 77.7091214
},
"southwest" : {
"lat" : 12.9206335,
"lng" : 77.6264824
}
},
"copyrights" : "Map data ©2015 Google",
"legs" : [
{
"distance" : {
"text" : "12.5 km",
"value" : 12510
},
"duration" : {
"text" : "29 mins",
"value" : 1750
},
"end_address" : "869, 12th Main Road, Koramangala 3 Block, Koramangala, Bengaluru, Karnataka 560034, India",
"end_location" : {
"lat" : 12.9280212,
"lng" : 77.6267905
},
"start_address" : "PFS Driveway, Lakshminarayana Pura, AECS Layout, Marathahalli, Bengaluru, Karnataka 560037, India",
"start_location" : {
"lat" : 12.959155,
"lng" : 77.70615509999999
},
}
],
"overview_polyline" : {
"points" : "wabnAo~gyMdL_AJFBd@BX@Dl@GU|F~@APkG^uKHqBF[D]g@Cy@lYAFErBInAUlGKfBArAA`@RJPJpFjAlLjBh@b@`Ft@lBRxNxAtC`@pB^fEbApCr@rLvCfCt@dAb@hCpAlD|AfEvB`CpAlAx@`Av@hDlDhLtM|MdOpIlJxF|Gp@~@h@`Ar@|AdGdPvD`K^z@vGvQ|@~B~C`I^jAp@tBbE|LtCbIpCdHhFbNT~@@VBp@Er@QhAeBxIYbB_A|Ga@zBk@lCaA|D_AfDcB~Gg@lCu@dGQb@Mv@gAhJ]dDEv@CpBSZUbA?tBJxBHbDLdCFrB?|DB|@BZHZvAvGhArGd@~BAf@IXwD|MO\\iAnBk@lAQd@K^Ov@En@Dp@pA`NHxAq@F|@dKz@hILzBKvAi@rB_Dk@oC]}D|L}D}@"
},
"summary" : "NH7",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}
答案 0 :(得分:0)
省略部分JSON响应不是API中的功能。
如果您想要这样做,请在问题跟踪器中执行此操作: async
但是,我不希望这是API的一部分。首先,它听起来有限,并且可以在您自己的服务器中实现:代理请求API,然后修剪响应。
也许您也可以使用SPDY: https://code.google.com/p/gmaps-api-issues/issues/entry?template=Directions%20API%20-%20Feature%20Request