0

I created a function in PHP that downloads a map created in google maps, I am able to download, however, the route is not coming when I am saving.

How the picture is coming:

enter image description here

How it should come:

enter image description here

Code:

function download_remote_file_with_curl($file_url, $save_to) {
    $arrContextOptions = array(
        "ssl" => array(
            "verify_peer" => false,
            "verify_peer_name" => false,
        ),
    );

    $response = file_get_contents($file_url, false, stream_context_create($arrContextOptions));
    //echo $response;
    //file_put_contents($save_to, $response);
    $downloaded_file = fopen($save_to, 'wb');
    fwrite($downloaded_file, $response);
    fclose($downloaded_file);
}


$urlDownload = "https://maps.googleapis.com/maps/api/staticmap?size=1000x1000&maptype=roadmap&path=enc:zklaAbqcyJzCmF~@b@fBdAzCiEnKyQlFpCnMdH~_@nU~JlFlCNrw@oL~IcApEZxd@nQpgBhq@tRtStgA``Aty@`o@ll@pa@tNhFzMvJfG~D|Y~Hxd@rMll@`Rtb@jLjNzExWtFz`@bJvM|ItG`LdF|V`GvD|CL|JiBv]aGld@cHrk@cLdU_Fpb@wGdMg@vaAqAti@g@z_@Cj~A{@raAfDlp@xAfYa@tyAuDtVEbTdApO`@rGk@dP`@vgEo@baCuA`|AaArHGIzAwCtHqDlNf@rl@lA~bAnAphAMj`@hBlj@\hd@s@tL\pHnCff@~A`|@lMnmEnBbKrFbDn`@jP~RtQ~k@hVhNtGb@xFgPheAsAnOuIlaBpj@|qCtDzGb`A~`AzDvGd@vI{Af_@x@~GxItHzLvGp\fLxc@t\pe@d`@h|AnmA`WvQnEDnF}Bd\uUjGeB~Gb@nEvB~KnMri@ni@fjCbfCpmArkAv|@pz@bjAjhApcEt}Ddx@pv@r_@lZzyB|hBtoHneGzZvVh|@xq@fb@jZh^fZjD~E`FlOzMbc@|L|`@hQrS~H`MhQ~w@hEdzB~B~hAbAbk@Ux^kNx~BeGriAaCbe@|@zSt@`ChDnBnZlAlFtCl`@`AzMpBpRvJlKvFbKlLxd@pcAdk@~oAjbAbiAnPxLfq@b^ndDpkBbdDfjBbqAdt@hFjAtNhCfMbD|g@tYhxDfxBrqFx~C|CpCzA|EE~E}i@raDsOb}@uO~{@{f@zvCr@hG~CdDf`Bly@hL|Lt@bClD|Brx@naAvAnAzb@lg@zj@veDjMbI|rBhdAlJzFdAjCbBpgBpMlsQdIhhO]p^?hb@z@dsAp@jo@l@pWffDp`FzyB~eDxdEhlGpNrSvv@hn@duEvuDnsJp~HtpLvvJ~bBtvAjw@hp@hDnFnHvpBlSh}FrFd_BvAno@tu@buTtPxwEnXvhJbRddGbQ~nGlNjqFlJv~BvC~rAdFppBvNhvEhShsGw@nQ}i@htBsq@lgCcJd]}BjPkG|y@gPptBu]byE_H~gArB`EfG|FxXnYfv@nv@nWhX`RjRjHj`@bfBdgKlCrKzGhQp`@lbAtdBnjEr_@z`A`~@n}Bth@fuAdpDzdJ|W`o@`ClAxIj@beA~A~p@bAx|F~I`lEzGvwAbCdMx@neDjlAbp@hUrE}@prB_qCzBaAjJAxOKhWfAfP?tm@}Q~{Bkr@r{EeyAxPoApfB~WzK|AHTdBDrO}A~RmBrXsCzZuA~NJx@bD|@dAfX`@{@nG&markers=color:green|label:A|-10.8819552,-61.95483539999998&markers=color:red|label:B|-12.457280801085,-64.2310285267651&key=yourkey";
download_remote_file_with_curl($urlDownload, realpath('C:/test') . '/' . 'test' . '.jpg');
?>

Thank you!

Diego
  • 21
  • 3
  • Possible duplicate of https://stackoverflow.com/questions/38302858/google-static-maps-with-directions – misorude Oct 29 '18 at 13:10
  • I'm not having an error in plotting the map, but in downloading – Diego Oct 29 '18 at 13:14
  • Start by properly URL-encoding the value of your path parameter, because it doesn't look like you did that at all. – misorude Oct 29 '18 at 13:16
  • Did you test the URL to know? You have to put the maps key at the end – Diego Oct 29 '18 at 13:18
  • I don't need to test this to see that you did not URL-encode this value, because multiple un-encoded characters are visible right at first glance. – misorude Oct 29 '18 at 13:27

1 Answers1

0

I don't know if what I'm about to write makes sense, but the route that you want to download is an item that appears once it's selected.

For example when the "SKIP" buttom in Youtube appears to quit an advertisement, it creates an instance of that box in HTML, and then it dissappears when Add is over.

I think that the route is this kind of instance and you must add a line of code to also take that piece of html

IceeFrog
  • 327
  • 3
  • 16