/** * ----------------------------------------------------------------------------- * file: gmapsPicture.js * file version: 1.1.1 * date: 2011-04-21 */ var viewportInitialized = { icon:false, meta:false }, markerImgProp = [ null, { w:32, h:32, x:15, y:31 }, // s01 { w:32, h:32, x:15, y:31 }, // s02 { w:32, h:32, x:10, y:31 }, // s03 { w:30, h:40, x:4, y:39 } // s04 ]; function applyMap(properties) { var latlng=new google.maps.LatLng(gmaps.coords.latitude, gmaps.coords.longitude), map = new google.maps.Map($("#"+properties.id).get(0), { mapTypeId: properties.mapType, zoom: properties.zoomLevel, center:latlng, navigationControl: (properties.navigationControl==-1)?false:true, scrollwheel: (properties.navigationControl==-1)?false:true, scaleControl: (properties.scaleControl=='n')?false:true, streetViewControl: (properties.streetViewControl=='n')?false:true, mapTypeControl:(properties.mapTypeControl==-1)?false:true, mapTypeControlOptions: { style:properties.mapTypeControl }, markerTitle:'' } ), marker = null; if(gmaps.geolocated) { marker= new google.maps.Marker( { position:latlng, map: map, title:properties.markerTitle } ); } re=/^mS(\d\d)_.*/i; iM=re.exec(properties.markerImg); if(iM!=null) iM=new Number(iM[1]); if(iM!=null && marker!=null) { var markerImg = new google.maps.MarkerImage('plugins/GMaps/img/'+properties.markerImg, new google.maps.Size(markerImgProp[iM].w, markerImgProp[iM].h), new google.maps.Point(0,0), new google.maps.Point(markerImgProp[iM].x, markerImgProp[iM].y)); marker.setIcon(markerImg); } if(properties.kmlFileUrl!='') { kmlFile = new google.maps.KmlLayer(properties.kmlFileUrl, { preserveViewport:true } ); } else { kmlFile=null; } map.kmlFile=kmlFile; properties.gMap=map; properties.gMapCenter=latlng; } /** * if picture is geolocated, center map on geolocation * otherwise, try to center on the kml file (by fitting bounds) */ function centerMap(map) { if(gmaps.geolocated) { map.gMap.setCenter(map.gMapCenter); } else { fitKmlBounds(map); } } /** * if map have a kml file, fit to kml bounds */ function fitKmlBounds(map) { if(map.gMap!=null) map.gMap.fitBounds(map.gMap.kmlFile.getDefaultViewport()); } $(window).load(function () { gmaps.popupMapIndex=-1; for(i=0;i>> */ if($('#iGMapContent').length>0) { tabId=$('#iGMapContent').get(0).parentNode.parentNode.id; tabId='tab'+tabId.toUpperCase().substring(0,1)+tabId.substr(1); $("#"+tabId+" a").bind('click', function () { if(viewportInitialized.meta==false) { for(i=0;i0) { $('#iGMapsIconContent').dialog( { autoOpen:false, width:$('#iGMapsIcon').width(), height:'auto', modal: true, closeText:'X', dialogClass: 'gmapsPopup', title: gmaps.maps[gmaps.popupMapIndex].title, open: function () { if(viewportInitialized.icon==false && gmaps.popupMapIndex!=-1) { if(gmaps.maps[gmaps.popupMapIndex].gMap.kmlFile!=null) gmaps.maps[gmaps.popupMapIndex].gMap.kmlFile.setMap(gmaps.maps[gmaps.popupMapIndex].gMap); google.maps.event.trigger(gmaps.maps[gmaps.popupMapIndex].gMap, 'resize'); centerMap(gmaps.maps[gmaps.popupMapIndex]); $('#iGMapsIcon span, #iGMapsIcon a').css('font-size', '55.0%'); viewportInitialized.icon=true; } google.maps.event.addListener( gmaps.maps[gmaps.popupMapIndex].gMap, 'dragend', function() { $('#gmapsCenterMap').css('display', 'inline'); $('#gmapsBoundKml').css('display', 'inline'); } ); google.maps.event.addListener( gmaps.maps[gmaps.popupMapIndex].gMap, 'zoom_changed', function() { $('#gmapsCenterMap').css('display', 'inline'); $('#gmapsBoundKml').css('display', 'inline'); } ); } } ); if(gmaps.geolocated) { $('div.gmapsPopup div.ui-dialog-titlebar') .append(''); $('#gmapsCenterMap').attr('title', gmaps.lang.centermap); } if(gmaps.maps[gmaps.popupMapIndex].gMap.kmlFile!=null) { $('div.gmapsPopup div.ui-dialog-titlebar') .append(''+ ''); $('#gmapsBoundKml').attr('title', gmaps.lang.boundkml); } } } );