Ignore:
Timestamp:
Dec 6, 2011, 5:42:24 AM (12 years ago)
Author:
rvelices
Message:

rv_gmaps towards full maps api v3 migration (still to test)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_gmaps/trunk/template/data_loader.js

    r8221 r12698  
    44        this.options = jQuery.fn.extend(
    55                {
    6                         reload_data_timeout: 1800,
    7                         rectangle_of_confusion: G_DEFAULT_ICON.iconSize
     6                        reload_data_timeout: 500,
     7                        rectangle_of_confusion: new google.maps.Size(32,16)
    88                }
    99                , opts || {} );
     
    3737{
    3838        this._urlMapData = urlMapData;
    39         google.maps.Event.bind( this._map, "movestart", this, this.clearTimerReloadData );
    40         google.maps.Event.bind( this._map, "moveend", this, this._onMapMoveEnd );
    41         this._loadData();
     39        google.maps.event.bind( this._map, "movestart", this, this.clearTimerReloadData );
     40        google.maps.event.bind( this._map, "idle", this, this._onIdle );
     41        //this._loadData();
    4242},
    4343
     
    5959},
    6060
    61 _onMapMoveEnd: function()
     61_onIdle: function()
    6262{
    6363        this.clearTimerReloadData();
     
    7878
    7979        var latRange = bounds.toSpan().lat();
    80         var latPrec = latRange * this.options.rectangle_of_confusion.height / this._map.getSize().height;
     80        var latPrec = latRange * this.options.rectangle_of_confusion.height / this._map.getDiv().offsetHeight;
    8181
    8282        var lonRange = bounds.toSpan().lng();
    83         var lonPrec = ( lonRange>=0 ? lonRange : 360-lonRange )* this.options.rectangle_of_confusion.width / this._map.getSize().width;
     83        var lonPrec = ( lonRange>=0 ? lonRange : 360-lonRange )* this.options.rectangle_of_confusion.width / this._map.getDiv().offsetWidth;
    8484
    8585        if ( this._previousLoadDataReq.box!=null )
    8686        { // not the first time
    87                 if ( this._previousLoadDataReq.box.containsBounds( bounds ) )
     87                if ( this._previousLoadDataReq.box.contains( bounds.getNorthEast() )
     88                                        && this._previousLoadDataReq.box.contains( bounds.getSouthWest() ))
    8889                {
    8990                        if ( this._previousLoadDataReq.resultBounds == null )
     
    109110
    110111        var nd=0, sd=0, ed=0, wd=0;
    111         if ( !bounds.isFullLat() )
     112        /*if ( !bounds.isFullLat() )*/
    112113        {
    113114                nd = latRange*12/100;
    114115                sd = latRange*4/100;
    115116        }
    116         if ( !bounds.isFullLng() )
     117        /*if ( !bounds.isFullLng() )*/
    117118        {
    118119                ed = lonRange*9/100;
     
    130131
    131132        if (document.is_debug) {
    132                 google.maps.Log.write("sd="+sd+" wd="+wd+" nd="+nd+" ed="+ed);
    133                 google.maps.Log.write( "bounds: " + this._map.getBounds().getSouthWest().toUrlValue() + " " + this._map.getBounds().getNorthEast().toUrlValue() +"; zoom: "+this._map.getZoom() +"; size: "+this._map.getSize().toString() +"; c: "+this._map.getCenter().toUrlValue() );
    134                 google.maps.Log.writeUrl( url );
     133                glog("sd="+sd+" wd="+wd+" nd="+nd+" ed="+ed);
     134                glog( url );
    135135        }
    136136
     
    141141
    142142        try {
    143                 google.maps.Event.trigger( this, "dataloading" );
     143                google.maps.event.trigger( this, "dataloading" );
    144144                jQuery.ajax( {
    145145                        url: url,
     
    151151                this._dataLoading = false;
    152152                this._previousLoadDataReq.box=null;
    153                 google.maps.Event.trigger( this, "dataloadfailed", 600, e );
     153                google.maps.event.trigger( this, "dataloadfailed", 600, e );
    154154        }
    155155},
     
    164164                        throw new Error( "DATA DECODING ERROR" );
    165165                this._previousLoadDataReq.resultBounds = resp.bounds;
    166                 if (document.is_debug && resp.debug) google.maps.Log.write( resp.debug );
    167                 google.maps.Event.trigger( this, "dataloaded", resp );
     166                if (document.is_debug && resp.debug) glog( resp.debug );
     167                google.maps.event.trigger( this, "dataloaded", resp );
    168168        }
    169169        catch (e)       {
    170170                this._previousLoadDataReq.box=null;
    171                 google.maps.Event.trigger( this, "dataloadfailed", responseCode, e );
     171                google.maps.event.trigger( this, "dataloadfailed", responseCode, e );
    172172                var s = e.message;
    173173                s += '\n' + data.substr(0,1000);
     
    182182{
    183183        try {
    184                 google.maps.Event.trigger( this, "dataloadfailed", textStatus + xhr.status, exc );
     184                google.maps.event.trigger( this, "dataloadfailed", textStatus + xhr.status, exc );
    185185        }
    186186        catch (e) {
Note: See TracChangeset for help on using the changeset viewer.