henrichen / zkgmapsz

Automatically exported from code.google.com/p/zkgmapsz
0 stars 0 forks source link

Gmaps supports Client ID #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently Gmaps does not support Client ID as an attribute, it would be better 
to support it so user can use their Client ID as below:

<gmaps clientID="CLIENT_ID" ... />

Original issue reported on code.google.com by benbai...@gmail.com on 18 Oct 2013 at 2:33

GoogleCodeExporter commented 9 years ago
currently can override widget function as a workaround

<zk xmlns:w="client">
    <gmaps width="500px" height="500px">
        <attribute w:name="_tryBind"><![CDATA[
            function(dt, skipper, after) {
                    var maskOpts;
                    if (maskOpts = this._maskOpts) {
                        if (maskOpts._mask && maskOpts._mask._opts) {
                                maskOpts._mask._opts.anchor = this;
                                maskOpts._mask.sync();
                        } else {
                                gmapsGapi.clearMask(this, maskOpts);
                                this._maskOpts = gmapsGapi.initMask(this, {message: 'Loading Google Maps APIs'});
                        }
                    }
                    if (!window.google || !window.google.maps) {
                        if (window.google && (!window.google.load  || window.google.loader.LoadFailure)) {
                            var n = jq(this.uuid, zk)[0];
                            n.innerHTML = gmaps.Gmaps.errormsg; 
                            return;  //failed to load the Google AJAX APIs
                        }
                        var wgt = this,
                                opts0 = {};
                        opts0['condition'] = function() {return window.google && window.google.maps;};
                        opts0['callback'] = function() {};

                        if (!opts0.condition()) {

                            gmapsGapi.waitUntil(wgt, opts0);
                            if (!gmaps.Gmaps.LOADING) { //avoid double loading Google Maps APIs
                                    gmaps.Gmaps.LOADING = true;
                                    if (!opts0.condition()) {
                                            var opts = ['sensor=',
                                                    this._sensor? this._sensor : 'false',
                                                    '&language=', this._language? this._language : '',
                                                    '®ion=', this._baseDomain? this._baseDomain : '',
                                                    '&libraries=', this._libraries? this._libraries : '',
/*  add your client id here >>>>>>>>>>>>>>>>>> 
*/  /*'&client=YOUR_CLIENT_ID'*/].join('');
                                        google.load('maps', this._version,
                                            {
                                                other_params: opts,
                                                callback: function(){// load marker manager after map api loaded
                                                    zk.loadScript(zk.ajaxURI('/web/js/gmaps/ext/markermanager.js', {desktop : this.desktop,au : true}));
                                                    wgt._realBind(dt, skipper, after);
                                                }
                                            }
                                        ); // load the maps api
                                    }
                            }
                        } else {
                            opts0['condition'] = function() {return window.MarkerManager;};
                            opts0['callback'] = function() {wgt._realBind(dt, skipper, after);};
                            gmapsGapi.waitUntil(wgt, opts0);
                        }
                    } else {
                        var wgt = this,
                                opts1 = [];
                        opts1['condition'] = function() {return window.MarkerManager;};
                        opts1['callback'] = function() {wgt._realBind(dt, skipper, after);};

                        gmapsGapi.waitUntil(wgt, opts1);
                    }
            }
        ]]></attribute>
    </gmaps>
</zk>

Original comment by benbai...@gmail.com on 18 Oct 2013 at 2:34

GoogleCodeExporter commented 9 years ago

Original comment by raymondchao@potix.com on 5 Dec 2013 at 9:31