Try this IFTTT receipt.


  Upload file from URL
  
  This Action will download a file at a given URL and add it to Google Drive at the path you specify.


Copy file from web to Google Drive
The main thing I want to achieve is that my module makes a google map with markers.

For now im doing this:

drupal_add_js('https://maps.googleapis.com/maps/api/js?key=AIzaSyDcl28Qcn9GTi02rRtQaLgVS4GWZbGcQ8E', 'external');

$locations = db_query('SELECT * FROM {locations}')-&gt;execute();

$script = '&lt;script&gt;
     function initialize() {

    var mapOptions = {
      center: { lat: 56.9714744, lng: 24.1291624},
      zoom: 9
    };
    var map = new google.maps.Map(document.getElementById(\'map-canvas\'),
        mapOptions);

    var locations = [';

    for($i = 0; $i &lt; $locations-&gt;length;$i++){
        $string = '['.$locations[$i]['locationsTitle'].','.$locations[$i]['locationsLat'].','.$locations[$i]['locationLng'].'],';
        $script = $script.$string;
    }

    $script = $script.'];
    for (var i = 0; i &lt; locations.length; i++) {

      var loc = new google.maps.LatLng(locations[i][1], locations[i][2]);

      var marker = new google.maps.Marker({
        position: loc,
        map: map,
        title: locations[i][0]
      });
    };

  }

  google.maps.event.addDomListener(window, \'load\', initialize);

&lt;/script&gt;
';

$html = '
&lt;div id="map-wrapper" style="width:100%;height:500px;margin:auto"&gt;
    &lt;ul id="map-list"&gt;&lt;/ul&gt;
    &lt;div id="map-canvas" style="width:100%;height:100%;margin:auto&gt;&lt;/div&gt;
&lt;/div&gt;
';

return array('#markup' =&gt; $script.$html);


As you can see in the third line of code im trying to get information from the database that I have saved. The problem is I dont know how would i get it properly. And then I want to pass it down in the var locations part in the script..

I have tried finding some tutorials where they explain how would this work but most of them is just how to show some posts or somthing like that and that doesnt help me.

Thanks for help already! :)

// EDIT

This is the script that i have now in js file

(function($) {
     Drupal.behaviors.myModule = {
       attach: function(context, settings) {

          function initialize() {

          var mapOptions = {
             center: { lat: 56.9714744, lng: 24.1291624},
             zoom: 9
          };
          var map = new google.maps.Map(document.getElementById('map-canvas'),
        mapOptions);

    var locations = [
                    ['Mājas',56.956344, 24.197409],
                    ['Domina',56.966058, 24.162004]
                    ];

    for (var i = 0; i &lt; locations.length; i++) {

      var loc = new google.maps.LatLng(locations[i][1], locations[i][2]);

      var marker = new google.maps.Marker({
        position: loc,
        map: map,
        title: locations[i][0]
      });
    };

  }

  //google.maps.event.addDomListener(window, 'load', initialize);

}


}
 )(jQuery);

I have the "google.maps.event.addDomListener(window, 'load', initialize);" commented becouse I think i dont need it..? And becouse there is no function initialize anymore? Or should i add that back?

The problem now is that my script seems to be added.. But it doesnt seem to be run becouse the google map dosnt show up..
