title: Pass parameters to a url callback function in JavaScript
body: <p>I have the following piece of code which displays a map when the user clicks on the submit button.</p>
  
  <p>At the moment the function initialize() takes no parameters and the map centers on a fixed latitude and longitude. I would like to be able to have latitude and longitude as parameters so that the map centers on those.</p>
  
  <p>I have the latitude and the longitude already so getting these parameters isn't the problem; my problem is that I don't know how to pass them to the function.</p>
  
  <p>Full code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
        &lt;link rel="stylesheet" type="text/css" href="stylesheet.css"&gt;
        &lt;title&gt;Simple Map&lt;/title&gt;
        &lt;meta name="viewport" content="initial-scale=1.0"&gt;
        &lt;meta charset="utf-8"&gt;
      &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="map"&gt;
  
          &lt;button type="button" onclick="loadScript()"&gt;submit&lt;/button&gt;
  
      &lt;/div&gt;
  
  
      &lt;script&gt;
  
          function initialize() {
              var latlng = new google.maps.LatLng(-34.397, 150.644);
              var myOptions = {
                  zoom: 10,
                  center: latlng,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              var map = new google.maps.Map(document.getElementById("map"),
          myOptions);
          }
  
  
          function loadScript() {
              var myKey = "myAPIKey";
              var script = document.createElement('script');
              script.type = 'text/javascript';
              script.src = "https://maps.googleapis.com/maps/api/js?key=" + myKey + "&amp;sensor=false&amp;callback=initialize";
              document.body.appendChild(script);
          }
  
      &lt;/script&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>JavaScript alone:</p>
  
  <pre><code>        function initialize() {
              var latlng = new google.maps.LatLng(-34.397, 150.644);
              var myOptions = {
                  zoom: 10,
                  center: latlng,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              var map = new google.maps.Map(document.getElementById("map"),
          myOptions);
          }
  
  
          function loadScript() {
              var myKey = "myAPIKey";
              var script = document.createElement('script');
              script.type = 'text/javascript';
              script.src = "https://maps.googleapis.com/maps/api/js?key=" + myKey + "&amp;sensor=false&amp;callback=initialize";
              document.body.appendChild(script);
          }
  </code></pre>