Ignore:
Timestamp:
Sep 23, 2011, 10:44:08 PM (13 years ago)
Author:
grum
Message:

fix bugs
bug:2346 - Preview / next arrow do not work with [gmaps] tag in description
bug:2063 - Incompatibility with slideshow mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GMaps/js/gmapsMarkup.js

    r10551 r12204  
    22 * -----------------------------------------------------------------------------
    33 * file: gmapsMarkup.js
    4  * file version: 1.1.1
    5  * date: 2011-04-13
     4 * file version: 1.1.2
     5 * date: 2011-09-23
    66 */
    77
    8 var markerImgProp = [
     8
     9 var gmapsCM=null,
     10     gmapsMM=null;
     11
     12function markupMaps()
     13{
     14  var markerImgProp = [
    915      null,
    1016      { w:32, h:32, x:15, y:31 }, // s01
     
    1420    ];
    1521
    16 
    17 function markupMaps()
    18 {
    1922  /**
    2023   * create the map
     
    9497      if(properties.fitToBounds)
    9598      {
    96         fitToBounds(map.bounds, gmapsIndex);
     99        this.fitToBounds(map.bounds, gmapsIndex);
    97100      }
    98101      else
     
    104107    if(properties.markerVisible)
    105108    {
    106       loadMarkers(map);
     109      this.loadMarkers(map);
    107110    }
    108111    else
    109112    {
    110       initializeMapViewport(gmapsIndex);
     113      this.initializeMapViewport(gmapsIndex);
    111114    }
    112115  };
     
    117120   * @param Map map : the map
    118121   */
    119   var loadMarkers = function(map)
    120   {
     122  this.loadMarkers = function(map)
     123  {
     124    var __this=this;
     125
    121126    if(map.getBounds()==null) return(false);
    122127    map.callId++;
     
    150155            {
    151156              tmp.markers.sort(compareMarkers);
    152               applyMarkers(gmapsMarkup.maps[tmp.loadIndex].gMap, tmp.markers);
    153               initializeMapViewport(tmp.loadIndex);
     157              __this.applyMarkers(gmapsMarkup.maps[tmp.loadIndex].gMap, tmp.markers);
     158              __this.initializeMapViewport(tmp.loadIndex);
    154159            }
    155160          }
     
    166171   *                          latitude, longitude, nbImg
    167172   */
    168   var applyMarkers = function(map, markers)
     173  this.applyMarkers = function(map, markers)
    169174  {
    170175    if(map==null) return(false);
     
    178183      while(i<map.markers.length)
    179184      {
    180         newListIndex=markerInList(map.markers[i].uId, markers);
     185        newListIndex=this.markerInList(map.markers[i].uId, markers);
    181186        if(newListIndex==-1)
    182187        {
     
    197202    for(var i=0;i<markers.length;i++)
    198203    {
    199       var marker = new google.maps.Marker(
    200         {
    201           position:new google.maps.LatLng(markers[i].lat, markers[i].lng),
    202           map: map,
    203           title:markers[i].nbImgTxt
    204         }
    205       );
     204      var __this=this,
     205          marker = new google.maps.Marker(
     206            {
     207              position:new google.maps.LatLng(markers[i].lat, markers[i].lng),
     208              map: map,
     209              title:markers[i].nbImgTxt
     210            }
     211          );
    206212
    207213      if(map.markerImg!=null) marker.setIcon(map.markerImg);
     
    224230          function ()
    225231          {
    226             displayWindowInfo(this);
     232            __this.displayWindowInfo(this);
    227233          }
    228234        );
     
    257263  };
    258264
    259   var markerInList=function(uniqueId, markerList)
     265  this.markerInList=function(uniqueId, markerList)
    260266  {
    261267    for(var i=0;i<markerList.length;i++)
     
    271277   * @param Marker marker : the marker
    272278   */
    273   var displayWindowInfo=function(marker)
    274   {
     279  this.displayWindowInfo=function(marker)
     280  {
     281    if(gmapsCM && gmapsCM instanceof categoryMaps) gmapsCM.closePictureInfo();
     282
    275283    gmapsMarkup.currentInfo=marker.info;
    276284    gmapsMarkup.infoWindow.close();
    277285    gmapsMarkup.infoWindow.setContent($('#iGMapsInfoWindowContent').clone().each(renameId).get(0));
    278286    gmapsMarkup.infoWindow.open(marker.map, marker);
    279     displayPictureInfo(gmapsMarkup.currentInfo.displayed);
     287    $('#ciWALeft, #ciWARight').unbind('click');
     288    $('#ciWARight').bind('click', function(event) { __this.displayPictureNext(); } );
     289    $('#ciWALeft').bind('click', function(event) { __this.displayPicturePrev(); } );
     290    this.displayPictureInfo(gmapsMarkup.currentInfo.displayed);
    280291  };
    281292  var renameId=function(i, e)
     
    286297
    287298
    288   /**
    289    *
    290    */
    291   var displayPictureInfo=function(index)
    292   {
     299  this.closePictureInfo = function ()
     300  {
     301    gmapsMarkup.currentInfo=null;
     302    gmapsMarkup.infoWindow.setContent('');
     303    gmapsMarkup.infoWindow.close();
     304    $('#ciWALeft, #ciWARight').unbind('click');
     305  }
     306
     307  /**
     308   *
     309   */
     310  this.displayPictureInfo=function(index)
     311  {
     312    var __this=this;
     313
     314    $('#ciWALeft,#ciWARight').unbind('click');
     315    $('#ciWARight').bind('click',
     316      function(event)
     317      {
     318        __this.displayPictureNext();
     319      }
     320    );
     321    $('#ciWALeft').bind('click',
     322      function(event)
     323      {
     324        __this.displayPicturePrev();
     325      }
     326    );
     327
    293328    gmapsMarkup.currentInfo.displayed=index;
    294329    if(gmapsMarkup.currentInfo.imgName[index]=='')
     
    344379    gmapsMarkup.currentInfo.displayed--;
    345380    if(gmapsMarkup.currentInfo.displayed<0) gmapsMarkup.currentInfo.displayed=gmapsMarkup.currentInfo.nbImg-1;
    346     displayPictureInfo(gmapsMarkup.currentInfo.displayed);
     381    this.displayPictureInfo(gmapsMarkup.currentInfo.displayed);
    347382  };
    348383
     
    354389    gmapsMarkup.currentInfo.displayed++;
    355390    if(gmapsMarkup.currentInfo.displayed>=gmapsMarkup.currentInfo.nbImg) gmapsMarkup.currentInfo.displayed=0;
    356     displayPictureInfo(gmapsMarkup.currentInfo.displayed);
     391    this.displayPictureInfo(gmapsMarkup.currentInfo.displayed);
    357392  };
    358393
     
    361396   * check if zoomLevel
    362397   */
    363   var fitToBounds=function(bounds, mapIndex)
     398  this.fitToBounds=function(bounds, mapIndex)
    364399  {
    365400    gmapsMarkup.maps[mapIndex].gMap.fitBounds(bounds);
     
    372407  };
    373408
    374   var initializeMapViewport=function(mapIndex)
    375   {
     409  this.initializeMapViewport=function(mapIndex)
     410  {
     411    var __this=this;
     412
    376413    if(mapIndex>-1 && !gmapsMarkup.maps[mapIndex].gMap.initialized)
    377414    {
     
    386423          function()
    387424          {
    388             loadMarkers(this);
     425            __this.loadMarkers(this);
    389426          }
    390427        );
     
    395432          function()
    396433          {
    397             loadMarkers(this);
     434            __this.loadMarkers(this);
    398435            gmapsMarkup.infoWindow.close();
    399436          }
     
    409446          function()
    410447          {
    411             fitToBounds(gmapsMarkup.maps[mapIndex].gMap.kmlFile.getDefaultViewport(), mapIndex);
     448            __this.fitToBounds(gmapsMarkup.maps[mapIndex].gMap.kmlFile.getDefaultViewport(), mapIndex);
    412449          }
    413450        );
     
    422459
    423460
    424 $(window).load(function ()
    425   {
    426     var mm=new markupMaps();
     461$(window).load(
     462  function ()
     463  {
     464    gmapsMM=new markupMaps();
    427465
    428466    // all maps have the same initials bounds
     
    434472     'closeclick',
    435473     function () {
    436        //$('body').append($('#iGMapsInfoWindowContent'));
    437474       gmapsMarkup.infoWindow.setContent('');
    438475       $('#ciGMIWC_img').unbind();
     
    465502              );
    466503
    467               mm.createMap(gmapsMarkup.maps[i], i);
     504              gmapsMM.createMap(gmapsMarkup.maps[i], i);
    468505            }
    469506          }
    470507      }
    471508    );
    472 
    473 
    474     if($('#iGMapsInfoWindow').length==0)
    475     {
    476       $('body').append($('<div/>',
    477                         {
    478                           id:'iGMapsInfoWindow',
    479                           css:{display:'none'},
    480                         }
    481                       ).append($('<div/>',
    482                                   {
    483                                     id:'iGMapsInfoWindowContent'
    484                                   }
    485                                 ).append($('<div/>',
    486                                             {
    487                                               id:'iGMIWC_title',
    488                                               html:'(title)'
    489                                             }
    490                                           )
    491                                         ).append($('<table/>',
    492                                                     {
    493                                                       id:'iGMIWC_thumb'
    494                                                     }
    495                                                   ).append($('<tr/>')
    496                                                             .append($('<td/>',
    497                                                                       {
    498                                                                         css:{width:'28px'}
    499                                                                       }
    500                                                                      ).append($('<div id="iWALeft" onclick="mm.displayPicturePrev();"/>')
    501                                                                              )
    502                                                                    )
    503                                                             .append($('<td/>').append($('<img/>',
    504                                                                                           {
    505                                                                                             id:'iGMIWC_img',
    506                                                                                             src:''
    507                                                                                           }
    508                                                                                         )
    509                                                                                       )
    510                                                                    )
    511                                                             .append($('<td/>',
    512                                                                       {
    513                                                                         css:{width:'28px'}
    514                                                                       }
    515                                                                     ).append($('<div id="iWARight" onclick="mm.displayPictureNext();">')
    516                                                                             )
    517                                                                   )
    518                                                           )
    519                                                 )
    520                                        .append($('<div/>',
    521                                                   {
    522                                                     id:'iGMIWC_picnum',
    523                                                     html:'0/0 photo'
    524                                                   }
    525                                                 )
    526                                               )
    527                                        .append($('<div/>',
    528                                                   {
    529                                                     id:'iGMIWC_showcat',
    530                                                     css:{display:'none'}
    531                                                   }
    532                                                 ).append($('<span/>',
    533                                                             {
    534                                                               html:'gmaps_i_show_this_picture_in'
    535                                                             }
    536                                                           )
    537                                                         )
    538                                                   .append($('<ul/>',
    539                                                             {
    540                                                               id:'iGMIWC_showcatList'
    541                                                             }
    542                                                           )
    543                                                         )
    544                                               )
    545                               )
    546                     );
    547     }
    548 
    549509  }
    550510);
Note: See TracChangeset for help on using the changeset viewer.