Ignore:
Timestamp:
Oct 29, 2010, 3:01:40 PM (13 years ago)
Author:
grum
Message:

implement feature:1950

File:
1 edited

Legend:

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

    r7308 r7479  
    4040              }
    4141            ),
    42       marker = new google.maps.Marker(
    43                   {
    44                     position:latlng,
    45                     map: map,
    46                     title:properties.markerTitle
    47                   }
    48                 );
    49 
     42      marker = null;
     43
     44  if(gmaps.geolocated)
     45  {
     46    marker= new google.maps.Marker(
     47      {
     48        position:latlng,
     49        map: map,
     50        title:properties.markerTitle
     51      }
     52    );
     53  }
    5054
    5155  re=/^mS(\d\d)_.*/i;
     
    5357  if(iM!=null) iM=new Number(iM[1]);
    5458
    55   if(iM!=null)
     59  if(iM!=null && marker!=null)
    5660  {
    5761    var markerImg = new google.maps.MarkerImage('plugins/GMaps/img/'+properties.markerImg,
     
    8488  properties.gMap=map;
    8589  properties.gMapCenter=latlng;
     90}
     91
     92/**
     93 * if picture is geolocated, center map on geolocation
     94 * otherwise, try to center on the kml file (by fitting bounds)
     95 */
     96function centerMap(map)
     97{
     98  if(gmaps.geolocated)
     99  {
     100    map.gMap.setCenter(map.gMapCenter);
     101  }
     102  else
     103  {
     104    fitKmlBounds(map);
     105  }
     106}
     107
     108/**
     109 * if map have a kml file, fit to kml bounds
     110 */
     111function fitKmlBounds(map)
     112{
     113  if(map.gMap!=null) map.gMap.fitBounds(map.gMap.kmlFile.getDefaultViewport());
    86114}
    87115
     
    127155      tabId='tab'+tabId.toUpperCase().substring(0,1)+tabId.substr(1);
    128156      $("#"+tabId+" a").bind('click', function ()
    129        {
     157        {
    130158          if(viewportInitialized.meta==false)
    131159          {
     
    135163              {
    136164                google.maps.event.trigger(gmaps.maps[i].gMap, 'resize');
    137                 gmaps.maps[i].gMap.setCenter(gmaps.maps[1].gMapCenter);
     165                centerMap(gmaps.maps[i]);
    138166                $('#'+gmaps.maps[i].id+' span, #'+gmaps.maps[i].id+' a').css('font-size', '55.0%');
    139167              }
     
    141169            viewportInitialized.meta=true;
    142170          }
    143        }
     171        }
    144172      );
    145173    }
     
    167195              if(viewportInitialized.icon==false && gmaps.currentMapLoadIndex!=-1)
    168196              {
    169                 google.maps.event.trigger(gmaps.maps[gmaps.currentMapLoadIndex].gMap, 'resize');
    170                 gmaps.maps[gmaps.currentMapLoadIndex].gMap.setCenter(gmaps.maps[gmaps.currentMapLoadIndex].gMapCenter);
    171                 $('#iGMapsIcon span, #iGMapsIcon a').css('font-size', '55.0%');
    172197                if(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile!=null)
    173198                  gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile.setMap(gmaps.maps[gmaps.currentMapLoadIndex].gMap);
     199
     200                google.maps.event.trigger(gmaps.maps[gmaps.currentMapLoadIndex].gMap, 'resize');
     201                centerMap(gmaps.maps[gmaps.currentMapLoadIndex]);
     202                $('#iGMapsIcon span, #iGMapsIcon a').css('font-size', '55.0%');
    174203                viewportInitialized.icon=true;
    175204              }
     
    198227      );
    199228
    200       $('div.gmapsPopup div.ui-dialog-titlebar')
    201       .append('<a href="#" id="gmapsCenterMap" style="display:none;" onclick="gmaps.maps[gmaps.currentMapLoadIndex].gMap.setCenter(gmaps.maps[gmaps.currentMapLoadIndex].gMapCenter); $(this).css(\'display\', \'none\').blur(); return(false);">'+
    202               '<span>&bull;</span></a>');
    203       $('#gmapsCenterMap').attr('title', gmaps.lang.centermap);
     229      if(gmaps.geolocated)
     230      {
     231        $('div.gmapsPopup div.ui-dialog-titlebar')
     232        .append('<a href="#" id="gmapsCenterMap" style="display:none;" onclick="centerMap(gmaps.maps[gmaps.currentMapLoadIndex]); $(this).css(\'display\', \'none\').blur(); return(false);">'+
     233                '<span>&bull;</span></a>');
     234        $('#gmapsCenterMap').attr('title', gmaps.lang.centermap);
     235      }
    204236
    205237      if(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile!=null)
    206238      {
    207239        $('div.gmapsPopup div.ui-dialog-titlebar')
    208           .append('<a href="#" id="gmapsBoundKml" onclick="gmaps.maps[gmaps.currentMapLoadIndex].gMap.fitBounds(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile.getDefaultViewport()); $(this).css(\'display\', \'none\').blur(); return(false);">'+
     240          .append('<a href="#" id="gmapsBoundKml" onclick="fitKmlBounds(gmaps.maps[gmaps.currentMapLoadIndex]); $(this).css(\'display\', \'none\').blur(); return(false);">'+
    209241                  '<span>&sim;</span></a>');
    210242        $('#gmapsBoundKml').attr('title', gmaps.lang.boundkml);
Note: See TracChangeset for help on using the changeset viewer.