
/**
 * jQuery gMap
 *
 * @url		http://gmap.nurtext.de/
 * @author	Cedric Kastner <cedric@nur-text.de>
 * @version	1.1.0
 */
(function(b){b.fn.gMap=function(f){if(!window.GBrowserIsCompatible||!GBrowserIsCompatible())return this;var a=b.extend({},b.fn.gMap.defaults,f);return this.each(function(){$gmap=new GMap2(this);$geocoder=new GClientGeocoder;if(a.address)$geocoder.getLatLng(a.address,function(d){$gmap.setCenter(d,a.zoom)});else if(a.latitude&&a.longitude)$gmap.setCenter(new GLatLng(a.latitude,a.longitude),a.zoom);else if(b.isArray(a.markers)&&a.markers.length>0)a.markers[0].address?$geocoder.getLatLng(a.markers[0].address, function(d){$gmap.setCenter(d,a.zoom)}):$gmap.setCenter(new GLatLng(a.markers[0].latitude,a.markers[0].longitude),a.zoom);else $gmap.setCenter(new GLatLng(34.885931,9.84375),a.zoom);$gmap.setMapType(a.maptype);if(a.controls.length==0)$gmap.setUIToDefault();else for(var c=0;c<a.controls.length;c++)eval("$gmap.addControl(new "+a.controls[c]+"());");a.scrollwheel==true&&a.controls.length!=0&&$gmap.enableScrollWheelZoom();for(c=0;c<a.markers.length;c++){marker=a.markers[c];gicon=new GIcon;gicon.image= a.icon.image;gicon.shadow=a.icon.shadow;gicon.iconSize=b.isArray(a.icon.iconsize)?new GSize(a.icon.iconsize[0],a.icon.iconsize[1]):a.icon.iconsize;gicon.shadowSize=b.isArray(a.icon.shadowsize)?new GSize(a.icon.shadowsize[0],a.icon.shadowsize[1]):a.icon.shadowsize;gicon.iconAnchor=b.isArray(a.icon.iconanchor)?new GPoint(a.icon.iconanchor[0],a.icon.iconanchor[1]):a.icon.iconanchor;gicon.infoWindowAnchor=b.isArray(a.icon.infowindowanchor)?new GPoint(a.icon.infowindowanchor[0],a.icon.infowindowanchor[1]): a.icon.infowindowanchor;if(marker.icon){gicon.image=marker.icon.image;gicon.shadow=marker.icon.shadow;gicon.iconSize=b.isArray(marker.icon.iconsize)?new GSize(marker.icon.iconsize[0],marker.icon.iconsize[1]):marker.icon.iconsize;gicon.shadowSize=b.isArray(marker.icon.shadowsize)?new GSize(marker.icon.shadowsize[0],marker.icon.shadowsize[1]):marker.icon.shadowsize;gicon.iconAnchor=b.isArray(marker.icon.iconanchor)?new GPoint(marker.icon.iconanchor[0],marker.icon.iconanchor[1]):marker.icon.iconanchor; gicon.infoWindowAnchor=b.isArray(marker.icon.infowindowanchor)?new GPoint(marker.icon.infowindowanchor[0],marker.icon.infowindowanchor[1]):marker.icon.infowindowanchor}if(marker.address){if(marker.html=="_address")marker.html=marker.address;$geocoder.getLatLng(marker.address,function(d,e){return function(g){gmarker=new GMarker(g,d);e.html&&gmarker.bindInfoWindowHtml(a.html_prepend+e.html+a.html_append);e.html&&e.popup&&gmarker.openInfoWindowHtml(a.html_prepend+e.html+a.html_append);gmarker&&$gmap.addOverlay(gmarker)}}(gicon, marker))}else{if(marker.html=="_latlng")marker.html=marker.latitude+", "+marker.longitude;gmarker=new GMarker(new GPoint(marker.longitude,marker.latitude),gicon);marker.html&&gmarker.bindInfoWindowHtml(a.html_prepend+marker.html+a.html_append);marker.html&&marker.popup&&gmarker.openInfoWindowHtml(a.html_prepend+marker.html+a.html_append);gmarker&&$gmap.addOverlay(gmarker)}}})};b.fn.gMap.defaults={address:"",latitude:0,longitude:0,zoom:1,markers:[],controls:[],scrollwheel:true,maptype:G_NORMAL_MAP, html_prepend:'<div class="gmap_marker">',html_append:"</div>",icon:{image:"http://www.google.com/mapfiles/marker.png",shadow:"http://www.google.com/mapfiles/shadow50.png",iconsize:[20,34],shadowsize:[37,34],iconanchor:[9,34],infowindowanchor:[9,2]}}})(jQuery);
