(function($){$.fn.gMaps=function(options){debug(this);var opts=$.extend({},$.fn.gMaps.defaults,options);return this.each(function(){var $this=$(this);var o=$.meta?$.extend({},opts,$this.data()):opts;var myLatlng=new google.maps.LatLng(o.latitude,o.longitude);var myOptions={zoom:o.zoom,center:myLatlng,disableDefaultUI:o.disableDefaultUI,mapTypeId:google.maps.MapTypeId[o.mapTypeId]};function addMarker(m){var nm,ni,infowindow,marker;nm={icon:m.icon||{image:null},latitude:m.latitude||o.latitude,longitude:m.longitude||o.longitude,infowindow:m.infowindow||false};marker=new google.maps.Marker({icon:nm.icon.image,position:new google.maps.LatLng(nm.latitude,nm.longitude),map:map,title:nm.infowindow.title||'Title'});if(nm.infowindow){ni='<div id="marker-content">'+'<h2>'+nm.infowindow.title+'</h2>'+'<div id="marker-body">'+nm.infowindow.text+'</div>'+'</div>';infowindow=new google.maps.InfoWindow({content:ni,maxWidth:nm.infowindow.maxWidth||300,maxHeigt:nm.infowindow.maxHeigt||300});if(nm.infowindow.open){infowindow.open(map,marker);}
google.maps.event.addListener(marker,'click',function(){infowindow.open(map,marker);});}}
var map=new google.maps.Map($this[0],myOptions);for(var i=0;i<o.markers.length;i++){addMarker(o.markers[i]);}});};function debug($obj){if(window.console&&window.console.log){window.console.log($obj);}}
$.fn.gMaps.defaults={latitude:45.448,longitude:9.178994,zoom:14,disableDefaultUI:true,mapTypeId:'ROADMAP',markers:[{latitude:45.442848,longitude:9.178994,infowindow:{title:"Qwent&egrave;s Italia S.r.l",text:"Via Meda 25, 20136<br />Milano<br />Italy",maxWidth:300,maxHeigt:300,open:true}}]};})(jQuery);
