jQuery.gmapp = { build : function(settings) { /* Default Settings*/ settings = jQuery.extend({ maptype: G_HYBRID_TYPE, center: [55.958858,-3.162302], zoom: 12, control: "small", showtype: true, showoverview: true, infoarea: "#gmapp-info" },settings); if (GBrowserIsCompatible()) { return this.each(function(){ var map = new GMap2 (this); var geocoder = new GClientGeocoder(); var infoarea = settings.infoarea; map.setCenter(new GLatLng(settings.center[0],settings.center[1]),settings.zoom,settings.maptype); switch(settings.control) { case "small": map.addControl(new GSmallMapControl()); break; case "large": map.addControl(new GLargeMapControl()); break; default: map.addControl(new GSmallMapControl()); } if (settings.showtype == true){ map.addControl(new GMapTypeControl()); } if (settings.showoverview == true){ map.addControl(new GOverviewMapControl()); } /* Seach for the lat & lng of our address*/ $('#findaddress').bind('click', function(){ jQuery.gmapp.searchAddress($('#Address').attr('value'), map, geocoder); }); }); } }, searchAddress : function(address,map,geocoder) { geocoder.getLatLng( address, function(point){ if (!point) { alert(address + " not found"); } else { map.setCenter(point,12); var marker = new GMarker(point, {draggable: true}); map.addOverlay(marker); /*marker.openInfoWindowHtml(address);*/ } }); } } jQuery.fn.gmapp = jQuery.gmapp.build;