;(function($) {/** * type: G_NORMAL_MAP | G_SATELLITE_MAP | G_HYBRID_MAP | G_PHYSICAL_MAP */$.extend($.fn, {googleMaps: function(settings) {settings = $.extend({type: G_NORMAL_MAP,address: false,dimensions: {width: 600,height: 400},marker: {icon: '',title: '',textMarker: '',textInfo: ''}}, settings);return $.fn.googleMaps.init(this, settings);}});$.extend($.fn.googleMaps, {init: function(el, settings) {var instance = this;var container = instance.getContainer($(el), settings.dimensions); 	if (GBrowserIsCompatible()) {   		if (!container.html()) { 		  	instance.MAP = new GMap2(container.get(0));  	 	 	instance.MAP.enableScrollWheelZoom();instance.MAP.addControl(new GLargeMapControl());instance.MAP.addControl(new GScaleControl());instance.MAP.addControl(new GMapTypeControl());instance.MAP.setCenter(new GLatLng(0, 0), 0);instance.MAP.setMapType(settings.type);}if (settings.address) {instance.getAddress(settings.address, function(ponto){$("#jquery-googlemaps-wrapper").show();//instance.addMarker(ponto, settings.marker);});}}return el;},getContainer: function(el, dimensions) {var container = $('#jquery-googlemaps-container');var wrapper = $('#jquery-googlemaps-wrapper');var link = $('<a href="#">Fechar</a>');var width = dimensions.width;var height = dimensions.height;if (!container.size() && !wrapper.size()) {container = $('<div id="jquery-googlemaps-container"></div>');wrapper = $('<div id="jquery-googlemaps-wrapper"></div>');container.css({width: width,height: height});wrapper.css({height: height,width: width,position: "absolute",top: el.offset().top + (el.height() - height)/2,left: el.offset().left + (el.width() - width)/2,backgroundColor: "#c4c4c4",display: "none" });link.css({display: "block",textAlign: "right",position: "relative",top: 0,right: 0});link.click(function(){wrapper.hide();return false;});wrapper.append(link);wrapper.append(container);wrapper.appendTo('body');}container.html("");wrapper.hide();return container;},getAddress: function(address, cb) {var geocoder = new GClientGeocoder(), instance = this;geocoder.getLocations(address, function (resposta) { if (!resposta || resposta.Status.code != G_GEO_SUCCESS) {alert("Nao foi possível localizar o endereco solicitado.");return false;}var total = resposta.Placemark.length;var local = resposta.Placemark[0];var ponto = local.Point.coordinates;var acc = resposta.Placemark[0].AddressDetails.Accuracy;instance.centerMap(ponto[1], ponto[0], acc);if (cb) cb.apply(instance, [ponto]);});},centerMap: function(x, y, acc) {var instance = this;instance.MAP.setCenter(new GLatLng(x, y), [3, 8, 10, 12, 13, 14, 15, 16, 17, 18][acc]);},//iconUrl, title, textMarker, textInfoaddMarker: function(ponto, marker) {var icon = new GIcon(), map = this.MAP;var latlng = new GLatLng(ponto[1], ponto[0]);    icon.image = iconUrl;    icon.iconSize = new GSize(32, 32);    icon.iconAnchor = new GPoint(32, 32);    icon.infoWindowAnchor = new GPoint(25, 7);var marker = new LabeledMarker(latlng, {   "icon": icon,  "clickable": true,  "title": title || '',  "labelText": textMarker || '',  "labelOffset": new GSize(-22, -24)   	});    GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(textInfo || 'Informações');    });   	map.addOverlay(marker);},clearMarkers: function() {var instance = this;instance.MAP.clearOverlays();}}); })(jQuery);