Google geocoding Response from Controller to Javascript
<p>I'm working on a Laravel 5.1 project and use <code>"alexpechkarev/google-geocoder": "dev-master"</code> which works perfectly.</p>

<p>A little issue comes in when I'm trying to print out the map with Javascript.
I get this response in my controller:</p>

<pre><code>$param = array(
                    "address"=&gt; $detail-&gt;address,
                    "components"=&gt;"country:NG"
                    );

                $response = \Geocoder::geocode('json', $param);

                echo "&lt;pre&gt;", print_r($response), "&lt;/pre&gt;";
</code></pre>

<p>And I get this response:</p>

<pre><code>{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Nigeria",
               "short_name" : "NG",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Nigeria",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 13.8856449,
                  "lng" : 14.677982
               },
               "southwest" : {
                  "lat" : 4.2464428,
                  "lng" : 2.676932
               }
            },
            "location" : {
               "lat" : 9.081999,
               "lng" : 8.675276999999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 13.8856449,
                  "lng" : 14.677982
               },
               "southwest" : {
                  "lat" : 4.2464428,
                  "lng" : 2.676932
               }
            }
         },
         "partial_match" : true,
         "place_id" : "ChIJDY2kfa8LThARyAvFaEH-qJk",
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}
1
</code></pre>

<p>My question is, how to get this response from controller to Javascript and pass it to the map.</p>

<p>Something like this:</p>

<pre><code>$('#map_canvas').gmap3({
            marker:{
                address: '40.717599,-74.005136' 
            },
            map:{
                options:{
                    zoom: 17,
                    scrollwheel: false,
                    streetViewControl : true
                }
            }
        });
</code></pre>

<p>Thanks.</p>