/** * :organization: Logilab * :copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. * :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr */Widgets.GMapWidget=defclass('GMapWidget',null,{__init__:function(wdgnode){// Assume we have imported google maps JSif(GBrowserIsCompatible()){varuselabelstr=wdgnode.getAttribute('cubicweb:uselabel');varuselabel=true;if(uselabelstr){if(uselabelstr=='True'){uselabel=true;}else{uselabel=false;}}varmap=newGMap2(wdgnode);map.addControl(newGSmallMapControl());varjsonurl=wdgnode.getAttribute('cubicweb:loadurl');varself=this;// bind this to a local variablejQuery.getJSON(jsonurl,function(geodata){if(geodata.center){varzoomLevel=geodata.zoomlevel;map.setCenter(newGLatLng(geodata.center.latitude,geodata.center.longitude),zoomLevel);}for(vari=0;i<geodata.markers.length;i++){varmarker=geodata.markers[i];self.createMarker(map,marker,i+1,uselabel);}});jQuery(wdgnode).after(this.legendBox);}else{// incompatible browserjQuery.unload(GUnload);}},createMarker:function(map,marker,i,uselabel){varpoint=newGLatLng(marker.latitude,marker.longitude);varicon=newGIcon();icon.image=marker.icon[0];icon.iconSize=newGSize(marker.icon[1][0],marker.icon[1][1]);icon.iconAnchor=newGPoint(marker.icon[2][0],marker.icon[2][1]);if(marker.icon[3]){icon.shadow4=marker.icon[3];}if(typeofLabeledMarker=="undefined"){vargmarker=newGMarker(point,{icon:icon,title:marker.title});}else{vargmarker=newLabeledMarker(point,{icon:icon,title:marker.title,labelText:uselabel?'<strong>'+i+'</strong>':'',labelOffset:newGSize(2,-32)});}map.addOverlay(gmarker);GEvent.addListener(gmarker,'click',function(){jQuery.post(marker.bubbleUrl,function(data){map.openInfoWindowHtml(point,data);});});}});