Uploaded image for project: 'ZK Gmaps'
  1. ZK Gmaps
  2. ZKGMAPS-28

allow gmap to also load additional libraries

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 3.2.0
    • 3.1.0
    • None

      we're using only GMaps to load Google additional Libraries (places, drawing and geometry). However, the libraries aren't loading well, because there are some kind of encode error on the loading Google URL.

      Function used to load libraries (included on first controller):
      private void loadResources() {
      if(this.getFellowIfAny("infodigg_gmaps_base") == null) {
      Gmaps gmaps = new Gmaps();
      String gApi = "XXXXX";
      gmaps.setKey(gApi);
      gmaps.setLibraries("geometry,drawing,places");
      Div div = new Div(); //ComponentsUtil.getDiv(null, gmaps);
      div.setStyle("height:1px; width: 1px; position: absolute; top: 0px; right: 0px");
      div.setId("infodigg_gmaps_base");
      this.appendChild(div);
      }
      }

      Javascript console: there aren't "window.google.maps.places" object (the library isn't loaded)

      Loaded "gmaps.wpd", versión 3.1.0 (latest)

      Google maps URL Generated:

      NOTE: If you replace in the URL: "https://maps.googleapis.com/maps/api/js?jsapiRedirect=true&key=XXXXXX&libraries=geometry%252Cdrawing%252Cplaces" the code "%252C" with "," the libraries are loaded ok. I think it's the way the libraries are loaded.

      UPDATE 2 We've found the problem and the solution: In line 646 of Gmaps.js, you're encoding the JS parameters:

      For example, if you make in Console:

      jq.param({libraries: 'geometry,drawing,places'})

      It generates:

      "libraries=geometry%2Cdrawing%2Cplaces"

      (And, Google Loader encode it again, generating wrong code)

      We propose something like this as solution (we've tested and it works):

      var str = "";
      if (this._gmapsApiConfigParams.libraries){
      var tmp = JSON.parse(JSON.stringify(this._gmapsApiConfigParams));
      str = "libraries=" + tmp.libraries;
      delete tmp.libraries;
      str = str + "&" + jq.param(tmp);
      } else {
      str = jq.param(this._gmapsApiConfigParams);
      }

      Solution proposed: Gmaps.zip

            cor3000 cor3000
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Remaining Estimate - 1 day
                1d
                Logged:
                Time Spent - Not Specified
                Not Specified