Show A Route On A Map
How can i show the following result: http://maps.googleapis.com/maps/api/directions/json?origin=hadera&destination=haifa&sensor=false on a map? i want to see the entire rou
Solution 1:
I assume you want to show the route on a Google Map, which is mandatory ;)
You can do this without using the JavaScript API, just use the Static Maps API with the path
parameter containing the encoded polyline you'll find in the overview_polyline
field of the route of your choice.
Example using the first route (that is, response.routes[0].overview_polyline.points
) from your sample request:
"overview_polyline" : {
"points" : "en_eEsoctEa@IuAvHzD~@hGrA~D~@i@vCgAlGa@|BqFp[kBOyBAgADk@Hw@JqBb@cIjAcC`@{Cr@iKrC_Bh@kDhAeCx@}Bn@}IpCcFtAq@Hs@D_A?yAEoAQi@OcA]kAg@}OoKmMqIkCgBoBgA}D{Bm@]ERiAxGoA`IYtAs@hCwAzDsB`EoDhGkDrGkBbDmBbD_CrC{@`AcAn@c@Pm@JUDa@?u@Cq@Mo@Um@c@cC}BmGgGgc@yd@qSmTsNiOwDoDqCmBkCuAcA]oC_AyCw@}Bc@_BO{BOwE@aDNiBRyARyBd@_K|Cag@bPsVdImDhAkBf@qCf@_AJqADeABcBCuAIqC_@kIqAuLaBgNmBuImAqFs@kL_BsEq@qEk@eGo@aFUqEIoOSiLI_DAgQQuDIiEa@u\\iDwBOiGw@yB_@uCy@yPsEaIwBiL_D{Cu@sAUgDk@uCYgAIeBCoEAax@nAgC@qCGcBIeCWmKmAmOaBkH_AqCc@}Aa@{CaAaBs@}BiAwMyGoAk@kBcAqHqDcBs@kC}@_D_AwCu@_BUgC[eDSeFIs@A{BFs`AtA_HH}CAoCIwBMsH]sMm@iMm@wG]qDYiFm@eFw@iCg@{Cs@cFsAwI}BqJgC{C{@cKmCuLaDuXmHwT_GuCu@sBc@wGkAqB[kDa@gE]eDQeGO{CCmC@}CFmCHcG\\yLx@wN`AcEXkETyDHiH@_DGgEO_F]sFi@oNuAgP_BwWgCsO{AuCa@eCe@eBa@wBm@uCaA}EwBwBiAaCyAsAaAyDcDoN_NmWqVgA_AiDeCwD_CyAy@wD_BeEyAsBk@kDs@uB]_CYyCU{AIyFOyCGyTW{SYiEEsJQ}ECyA@mDLyFVoCVyBZyCd@aDv@kDdAkA^gAh@qDrAsLtFmInDoBt@oAd@eATcG`AmCLo@Ds@?oCEeAG{lB_VaM{AyGs@aHYuISeB?gHMiLYyJe@gO{AwCUwGs@yf@_FaFc@u@KqI{@{Iy@wEa@{De@gO{AqC]mHk@gEOoPUoOQ_S[kKOmBIkBWs@Q}@[}@e@eAy@{AkBoAgBqDmHi@eAs@_Ae@e@sAaAcAm@_Ac@}@U_AM_BK}BM]@eCEyBJaALs@LsA\\_Bv@{BlAiBhAyAx@{Ap@wCtAaFjC_CfAwBv@cB\\kDt@_LnBwJbBmEb@gJp@M@{BLcD`@cDX}E`@_CLuBCcEWmKk@{Dg@cCYaEgAqCoAoBwAcCgC}EmGg@m@gDkEuE{FiBwBoBsCkAwB}@wBo@gCa@sCMqAMoD@uIBkDFuQ@qDBy@"
},
Resulting map:
Full request, requires URL-encoding the encoded polyline:
Solution 2:
how about google's support for embedding? or how to add google maps to your website
the easiest way to use it is go to actual google maps and use the link button, then use the link in your site/whatever
Post a Comment for "Show A Route On A Map"