All pastes #614295 Raw Edit

digitalspaghetti

public javascript v1 · immutable
·published 2007-07-11 13:51 UTC
rendered paste body
/* * Google Map Application (GMApp) * Author: Tane Piper (digitalspaghetti@gmail.com) * Website: http://digitalspaghetti.tooum.net * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php *  * === Changelog === * Version 0.1 * + Initial Version *  * === Instructions === * Create your div and form.  The form submit button must be called id="findaddress". * Then insert your jQuery to activate (i.e. $('#mydiv').gmapp(); * Now type in the address or postcode to search for the location you like, this will drop * a marker there, which you can drag around. */jQuery.gmapp = {		buildApp : function(settings) {				var version = "0.1";				/* 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",			geocode: "#Address",			latfield: "#VenueLatitude",			lngfield: "#VenueLongitude",			loadpoints: "/venues/"		},settings);				if (GBrowserIsCompatible())		{			return this.each(function(){				this.GMap2 = new GMap2(this);				GGeocoder = new GClientGeocoder();				var infoarea = settings.infoarea;								this.GMap2.setCenter(new GLatLng(settings.center[0],settings.center[1]),settings.zoom,settings.maptype);								switch(settings.control)				{					case "small":						this.GMap2.addControl(new GSmallMapControl());						break;					case "large":						this.GMap2.addControl(new GLargeMapControl());						break;					default:						this.GMap2.addControl(new GSmallMapControl());				}							if (settings.showtype == true){					this.GMap2.addControl(new GMapTypeControl());				}				if (settings.showoverview == true){					this.GMap2.addControl(new GOverviewMapControl());				}				/*jQuery(this).after('<p><strong>Google Map Application Version ' + version + '</strong></p>');*/								/* Seach for the lat & lng of our address*/				jQuery('#findaddress').bind('click', function(){					jQuery.gmapp.searchAddress(jQuery(settings.geocode).attr('value'), GGeocoder, infoarea);				});				});		}	},		searchAddress : function(address, GGeocoder, infoarea) {		GGeocoder.getLatLng(		address,		function(point){			if (!point) {				alert(address + " not found");			} else {				this.GMap2.setCenter(point,12);				var marker = new GMarker(point, {draggable: true});				this.GMap2.addOverlay(marker);				marker.openInfoWindowHtml("Lat: " + point.lat() + " Lng: " + point.lng());				GEvent.addListener(marker, "dragend", function(){					mylocation = marker.getPoint();					marker.openInfoWindowHtml("Latitude: " + mylocation.lat() + "<br />Longitude: " + mylocation.lng());							});							}		});	},		GMap2 : function() {		return this[0].GMap2;	}}jQuery.fn.gmapp = jQuery.gmapp.buildApp;jQuery.fn.GMap2 = jQuery.gmapp.GMap2