5 Replies Latest reply: Jul 19, 2013 11:00 AM by Bradley Coyne RSS

    Extensions problem with external JS

      Hi All,

      I have a little challenge with extensions. I am trying to include the GoogleMaps API. I know the solution on static maps but this is not satisfaying enough for my needs. Therefore I thought about writing my own extension. But for some reason I can't get it working. The below is a simplified extract, which simply loads the JS script from Google and then should create an object based on the Google API. Unfortunately, the execution stops after the alert("in") statement. I believe the latlng object can't be created because the Google Javascript is unknown (although loaded before).

      Any ideas? Here is the code...

       

       

      Qva.AddExtension('GoogleMaps', function() {

      var script = document.createElement("script")

      script.setAttribute("type", "text/javascript");

      script.setAttribute("src", "http://maps.google.com/maps/api/js?sensor=true");

      this.Element.appendChild(script);

      script = document.createElement("script");

      script.setAttribute("type", "text/javascript");

      this.Element.appendChild(script);

       

      alert (this.Element.innerHTML);

       

      initialize();

       

      });

       

      function initialize() {

      alert ("in");

      var latlng = new google.maps.LatLng(48, 8);

      alert(latlng);

      var myOptions = {

      zoom: 4,

      center: latlng,

      mapTypeId: google.maps.MapTypeId.SATELLITE

      };

      }



       

      cheers

      Florian