source: extensions/GMaps/js/gmapsMarkup.min.js @ 10551

Last change on this file since 10551 was 10551, checked in by grum, 13 years ago

bug:2148 - compatibility with piwigo 2.2
bug:2062 - compatibility with IE7

File size: 8.6 KB
Line 
1/* file: gmapsMarkup.js - v1.1.1 | minified on 2011/04/13 with http://jscompress.com/ */
2var markerImgProp=[null,{w:32,h:32,x:15,y:31},{w:32,h:32,x:15,y:31},{w:32,h:32,x:10,y:31},{w:30,h:40,x:4,y:39}];function markupMaps()
3{this.createMap=function(properties,gmapsIndex)
4{var bounds=new google.maps.LatLngBounds(new google.maps.LatLng(properties.mapBounds.south,properties.mapBounds.west),new google.maps.LatLng(properties.mapBounds.north,properties.mapBounds.east)),map=new google.maps.Map($("#"+properties.id).get(0),{backgroundColor:'#ffffff',mapTypeId:properties.mapType,zoom:properties.zoomLevel,center:bounds.getCenter(),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:''});if(properties.kmlFileUrl!='')
5{kmlFile=new google.maps.KmlLayer(properties.kmlFileUrl,{preserveViewport:true});kmlFile.setMap(map);}
6else
7{kmlFile=null;}
8re=/^mS(\d\d)_.*/i;iM=re.exec(properties.markerImg);if(iM!=null)iM=new Number(iM[1]);if(iM!=null)
9{map.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));}
10else
11{map.markerImg=null;}
12map.bounds=bounds;map.kmlFile=kmlFile;map.markers=new Array();map.gmapsIndex=gmapsIndex;map.width=properties.width;map.height=properties.height;map.callId=0;map.allowBubble=properties.allowBubble;map.initialized=false;properties.gMap=map;if(properties.geolocated)
13{if(properties.fitToBounds)
14{fitToBounds(map.bounds,gmapsIndex);}
15else
16{map.setCenter(map.bounds.getCenter());}}
17if(properties.markerVisible)
18{loadMarkers(map);}
19else
20{initializeMapViewport(gmapsIndex);}};var loadMarkers=function(map)
21{if(map.getBounds()==null)return(false);map.callId++;datas={requestId:gmapsMarkup.requestId,callId:map.callId,bounds:{north:map.getBounds().getNorthEast().lat(),east:map.getBounds().getNorthEast().lng(),south:map.getBounds().getSouthWest().lat(),west:map.getBounds().getSouthWest().lng()},width:map.width,height:map.height,distanceTreshold:20,loadIndex:map.gmapsIndex};$.ajax({type:"POST",url:"plugins/GMaps/gmaps_ajax.php",async:true,data:{ajaxfct:"public.maps.getMarkers",datas:datas},success:function(msg)
22{tmp=$.parseJSON(msg);if(gmapsMarkup.maps[tmp.loadIndex].gMap.callId==tmp.callId)
23{tmp.markers.sort(compareMarkers);applyMarkers(gmapsMarkup.maps[tmp.loadIndex].gMap,tmp.markers);initializeMapViewport(tmp.loadIndex);}}});};var applyMarkers=function(map,markers)
24{if(map==null)return(false);if(map.markers.length>0)
25{var i=0;while(i<map.markers.length)
26{newListIndex=markerInList(map.markers[i].uId,markers);if(newListIndex==-1)
27{map.markers[i].marker.setMap(null);map.markers.splice(i,1);}
28else
29{markers.splice(newListIndex,1);i++;}}}
30for(var i=0;i<markers.length;i++)
31{var marker=new google.maps.Marker({position:new google.maps.LatLng(markers[i].lat,markers[i].lng),map:map,title:markers[i].nbImgTxt});if(map.markerImg!=null)marker.setIcon(map.markerImg);marker.info=markers[i];marker.info.displayed=0;map.markers.push({marker:marker,uId:markers[i].uId});if(map.allowBubble)
32{google.maps.event.addListener(marker,'click',function()
33{displayWindowInfo(this);});}
34for(var index=0;index<marker.info.imgTn.length;index++)
35{switch(marker.info.imgTn[index].charAt(0))
36{case'G':marker.info.imgTn[index]='./galleries/'+marker.info.imgTn[index].substr(1);break;case'U':marker.info.imgTn[index]='./upload/'+marker.info.imgTn[index].substr(1);break;}}}};var compareMarkers=function(m1,m2)
37{if(m1.uId<m2.uId)
38{return(-1);}
39else if(m1.uId<m2.uId)
40{return(1);}
41return(0);};var markerInList=function(uniqueId,markerList)
42{for(var i=0;i<markerList.length;i++)
43{if(markerList[i].uId==uniqueId)return(i)}
44return(-1);};var displayWindowInfo=function(marker)
45{gmapsMarkup.currentInfo=marker.info;gmapsMarkup.infoWindow.close();gmapsMarkup.infoWindow.setContent($('#iGMapsInfoWindowContent').clone().each(renameId).get(0));gmapsMarkup.infoWindow.open(marker.map,marker);displayPictureInfo(gmapsMarkup.currentInfo.displayed);};var renameId=function(i,e)
46{if(e.id!='')e.id='c'+e.id;$(e).children().each(renameId);};var displayPictureInfo=function(index)
47{gmapsMarkup.currentInfo.displayed=index;if(gmapsMarkup.currentInfo.imgName[index]=='')
48{$('#ciGMIWC_title').html(' ');}
49else
50{$('#ciGMIWC_title').html(gmapsMarkup.currentInfo.imgName[index]);}
51$('#ciGMIWC_img').attr('src',gmapsMarkup.currentInfo.imgTn[index]);$('#ciGMIWC_img').unbind();if(gmapsMarkup.currentInfo.imgCatsUrl[index].length==1)
52{$('#ciGMIWC_img').bind('click',function()
53{window.location=gmapsMarkup.currentInfo.imgCatsUrl[gmapsMarkup.currentInfo.displayed][0];});}
54else
55{$('#ciGMIWC_showcatList').html('');for(var i=0;i<gmapsMarkup.currentInfo.imgCatsUrl[index].length;i++)
56{$('#ciGMIWC_showcatList').append('<li><a href="'+gmapsMarkup.currentInfo.imgCatsUrl[index][i]+'">'+gmapsMarkup.currentInfo.imgCatsNames[index][i]+'</a></li>');}
57$('#ciGMIWC_img, #ciGMIWC_showcat').bind('mouseenter',function(){$('#ciGMIWC_showcat').css('display','block');}).bind('mouseleave',function(){$('#ciGMIWC_showcat').css('display','none');});}
58if(gmapsMarkup.currentInfo.nbImg>1)
59{$('#ciGMIWC_picnum').html((index+1)+'/'+gmapsMarkup.currentInfo.nbImgTxt);$('#ciWALeft, #ciWARight').css('display','inline-block');}
60else
61{$('#ciGMIWC_picnum').html(gmapsMarkup.currentInfo.nbImgTxt);$('#ciWALeft, #ciWARight').css('display','none');}};this.displayPicturePrev=function()
62{gmapsMarkup.currentInfo.displayed--;if(gmapsMarkup.currentInfo.displayed<0)gmapsMarkup.currentInfo.displayed=gmapsMarkup.currentInfo.nbImg-1;displayPictureInfo(gmapsMarkup.currentInfo.displayed);};this.displayPictureNext=function()
63{gmapsMarkup.currentInfo.displayed++;if(gmapsMarkup.currentInfo.displayed>=gmapsMarkup.currentInfo.nbImg)gmapsMarkup.currentInfo.displayed=0;displayPictureInfo(gmapsMarkup.currentInfo.displayed);};var fitToBounds=function(bounds,mapIndex)
64{gmapsMarkup.maps[mapIndex].gMap.fitBounds(bounds);if(gmapsMarkup.maps[mapIndex].zoomLevelMaxActivated&&gmapsMarkup.maps[mapIndex].gMap.getZoom()>gmapsMarkup.maps[mapIndex].zoomLevel)
65{gmapsMarkup.maps[mapIndex].gMap.setZoom(gmapsMarkup.maps[mapIndex].zoomLevel);}};var initializeMapViewport=function(mapIndex)
66{if(mapIndex>-1&&!gmapsMarkup.maps[mapIndex].gMap.initialized)
67{$('#'+gmapsMarkup.maps[mapIndex].id+' span, #'+gmapsMarkup.maps[mapIndex].id+' a').css('font-size','55.0%');if(gmapsMarkup.maps[mapIndex].markerVisible)
68{google.maps.event.addListener(gmapsMarkup.maps[mapIndex].gMap,'dragend',function()
69{loadMarkers(this);});google.maps.event.addListener(gmapsMarkup.maps[mapIndex].gMap,'zoom_changed',function()
70{loadMarkers(this);gmapsMarkup.infoWindow.close();});}
71if(gmapsMarkup.maps[mapIndex].kmlZoom&&gmapsMarkup.maps[mapIndex].gMap.kmlFile!=null)
72{google.maps.event.addListenerOnce(gmapsMarkup.maps[mapIndex].gMap.kmlFile,'defaultviewport_changed',function()
73{fitToBounds(gmapsMarkup.maps[mapIndex].gMap.kmlFile.getDefaultViewport(),mapIndex);});}
74gmapsMarkup.maps[mapIndex].gMap.initialized=true;}};}
75$(window).load(function()
76{var mm=new markupMaps();gmapsMarkup.currentInfo=null;gmapsMarkup.infoWindow=new google.maps.InfoWindow();google.maps.event.addListener(gmapsMarkup.infoWindow,'closeclick',function(){gmapsMarkup.infoWindow.setContent('');$('#ciGMIWC_img').unbind();});$.ajax({type:"POST",url:"plugins/GMaps/gmaps_ajax.php",async:true,data:{ajaxfct:"public.maps.init",category:gmapsMarkup.categoryId,mapId:'y'},success:function(msg)
77{gmapsMarkup.requestId=msg;for(var i=0;i<gmapsMarkup.maps.length;i++)
78{$('#'+gmapsMarkup.maps[i].id).css({width:gmapsMarkup.maps[i].width+'px',height:gmapsMarkup.maps[i].height+'px'});mm.createMap(gmapsMarkup.maps[i],i);}}});if($('#iGMapsInfoWindow').length==0)
79{$('body').append($('<div/>',{id:'iGMapsInfoWindow',css:{display:'none'},}).append($('<div/>',{id:'iGMapsInfoWindowContent'}).append($('<div/>',{id:'iGMIWC_title',html:'(title)'})).append($('<table/>',{id:'iGMIWC_thumb'}).append($('<tr/>').append($('<td/>',{css:{width:'28px'}}).append($('<div id="iWALeft" onclick="mm.displayPicturePrev();"/>'))).append($('<td/>').append($('<img/>',{id:'iGMIWC_img',src:''}))).append($('<td/>',{css:{width:'28px'}}).append($('<div id="iWARight" onclick="mm.displayPictureNext();">'))))).append($('<div/>',{id:'iGMIWC_picnum',html:'0/0 photo'})).append($('<div/>',{id:'iGMIWC_showcat',css:{display:'none'}}).append($('<span/>',{html:'gmaps_i_show_this_picture_in'})).append($('<ul/>',{id:'iGMIWC_showcatList'})))));}});
Note: See TracBrowser for help on using the repository browser.