<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: maps code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 15:43:00 GMT</pubDate>
    <description>DZone Snippets: maps code</description>
    <item>
      <title>jQuery Maps Interface - Easily create Google or Yahoo maps</title>
      <link>http://snippets.dzone.com/posts/show/4361</link>
      <description>/* jQuery Maps (jmaps) - A jQuery plugin for Google Maps API&lt;br /&gt; * Author: Tane Piper (digitalspaghetti@gmail.com) &lt;br /&gt; * With special thanks Dave Cardwell (who helped on getting the first version of this plugin to work).&lt;br /&gt; * Website: http://code.google.com/p/gmapp/&lt;br /&gt; * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php&lt;br /&gt; * This plugin is not affiliated with Google or Yahoo.  &lt;br /&gt; * For Google Maps API and T&amp;C see http://www.google.com/apis/maps/&lt;br /&gt; * For Yahoo! Maps API and T&amp;C see http://developer.yahoo.com/maps/&lt;br /&gt; * &lt;br /&gt; * === Changelog ===&lt;br /&gt; * Version 1.3&lt;br /&gt; * Added support for creating Yahoo! Maps, can create Map, Satallite or Hybrid.  Check out available options below&lt;br /&gt; * Added support for creating points on Yahoo! maps.&lt;br /&gt; * Added support for creating Polylines on Yahoo! maps.&lt;br /&gt; * Added support for GeoRSS files on both Yahoo! and Google maps, as well as existing KML support for Google, method&lt;br /&gt; * name was changed from .addKml to .addRss&lt;br /&gt; * Moved directions search out of main namespace, now function that is called from within plugin by providing fields&lt;br /&gt; * &lt;br /&gt; * Version 1.2 (25/07/2007)&lt;br /&gt; * Moved GClientGeocoder into searchAddress method&lt;br /&gt; * Fixed bug in searchAddress method regarding getPoint().&lt;br /&gt; * &lt;br /&gt; * Version 1.1 (16/07/2007)&lt;br /&gt; * Changed name to remove Google from main name - namespace now .jmap.&lt;br /&gt; * Added additional options:&lt;br /&gt; * 	+ Add map dragging enable/disable.&lt;br /&gt; *	+ Add scroll wheel zooming.&lt;br /&gt; *	+ Add smooth continuous zooming (on certain browsers).&lt;br /&gt; *	+ Added clean unloading of Google objects.&lt;br /&gt; * Added .addPoly method.  Allows the creation of polylines on the map.&lt;br /&gt; * Added .addKml support for rendering KML Files.&lt;br /&gt; * Added .directions Driving Direction support.&lt;br /&gt; * &lt;br /&gt; * Version 1.0 (13/07/2007)&lt;br /&gt; * Initial version.&lt;br /&gt; * Creates Google Map.&lt;br /&gt; * Add points to map.&lt;br /&gt; * Takes address or postcode, Geocodes and centers map.  Also creates a draggable marker.&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;(function($) {&lt;br /&gt;	/* function searchAddress(jmap, address, settings)&lt;br /&gt;	 * This function is an internal plugin method that returns a GLatLng that can be passed&lt;br /&gt;	 * to a Google map.&lt;br /&gt;	 */&lt;br /&gt;	function searchAddress(jmap, address, settings) {&lt;br /&gt;		&lt;br /&gt;		if (jmap._mapType) {&lt;br /&gt;			alert('Yahoo Maps Geocoding not yet supported');&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;		if (jmap.i.Au) {&lt;br /&gt;			GGeocoder = new GClientGeocoder();&lt;br /&gt;			GGeocoder.getLatLng(address, function(point){&lt;br /&gt;				if (!point) {&lt;br /&gt;					alert(address + " not found");&lt;br /&gt;				} else {&lt;br /&gt;					jmap.setCenter(point,settings.zoom);&lt;br /&gt;					var marker = new GMarker(point, {draggable: true});&lt;br /&gt;					jmap.addOverlay(marker);&lt;br /&gt;					pointlocation = marker.getPoint();&lt;br /&gt;					marker.openInfoWindowHtml("Latitude: " + pointlocation.lat() + "&lt;br /&gt;Longitude: " + pointlocation.lng());&lt;br /&gt;					GEvent.addListener(marker, "dragend", function(){&lt;br /&gt;						mylocation = marker.getPoint();&lt;br /&gt;						marker.openInfoWindowHtml("Latitude: " + pointlocation.lat() + "&lt;br /&gt;Longitude: " + pointlocation.lng());			&lt;br /&gt;					});&lt;br /&gt;				}&lt;br /&gt;			});&lt;br /&gt;		}	&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	/* directions: function(map,query, panel)&lt;br /&gt;	 * Takes a Direction query and returns directions for map.  Optional panel for text information&lt;br /&gt;	 */&lt;br /&gt;	function searchDirections(jmap,query,panel) {&lt;br /&gt;		// Yahoo Maps&lt;br /&gt;		if (jmap._mapType) {&lt;br /&gt;			alert('Yahoo Directions support not yet added')	;&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;		// Google Maps&lt;br /&gt;		if (jmap.i.Au) {&lt;br /&gt;			var dirpanel = document.getElementById(panel);&lt;br /&gt;			directions = new GDirections(jmap, dirpanel);&lt;br /&gt;			directions.load(query);&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	$.fn.extend({&lt;br /&gt;	/* jmap: function(settings)&lt;br /&gt;	 * The constructor method&lt;br /&gt;	 * Example: $().jmap();&lt;br /&gt;	 */&lt;br /&gt;	jmap: function(settings) {&lt;br /&gt;		var version = "1.3";&lt;br /&gt;		/* Default Settings*/	&lt;br /&gt;		var settings = jQuery.extend({&lt;br /&gt;			provider: "google",		// can be "google" or "yahoo"&lt;br /&gt;			maptype: "hybrid",		// can be "map", "sat" or "hybrid"&lt;br /&gt;			center: [55.958858,-3.162302],	// G + Y&lt;br /&gt;			zoom: 12,				// G + Y&lt;br /&gt;			controlsize: "small",	// G + Y&lt;br /&gt;			showtype: true,			// G + Y&lt;br /&gt;			showzoom: true,			// Y&lt;br /&gt;			showpan: true,			// Y&lt;br /&gt;			showoverview: true,		// G&lt;br /&gt;			showscale: true,		// Y&lt;br /&gt;			dragging: true,			// G + Y&lt;br /&gt;			scrollzoom: true,		// G + Y&lt;br /&gt;			smoothzoom: true,		// G&lt;br /&gt;			searchfield: "#Address",&lt;br /&gt;			searchbutton: "#findaddress",&lt;br /&gt;			directionsto: "#to",&lt;br /&gt;			directionsfrom: "#from",&lt;br /&gt;			directionsfind: "#getDirections",&lt;br /&gt;			directionspanel: "myDirections"&lt;br /&gt;		},settings);&lt;br /&gt;		&lt;br /&gt;		return this.each(function(){&lt;br /&gt;			switch(settings.provider)&lt;br /&gt;			{&lt;br /&gt;				case "yahoo":&lt;br /&gt;					var jmap = this.jMap = new YMap(this);&lt;br /&gt;					switch(settings.maptype) {&lt;br /&gt;						case "map":&lt;br /&gt;							var loadmap = YAHOO_MAP_REG;&lt;br /&gt;							break;&lt;br /&gt;						case "sat":&lt;br /&gt;							var loadmap = YAHOO_MAP_SAT;&lt;br /&gt;							break;&lt;br /&gt;						default:&lt;br /&gt;							var loadmap = YAHOO_MAP_HYB;&lt;br /&gt;							break;&lt;br /&gt;					}&lt;br /&gt;					jmap.setMapType(loadmap);&lt;br /&gt;					jmap.drawZoomAndCenter(new YGeoPoint(settings.center[0],settings.center[1]), settings.zoom);&lt;br /&gt;					if (settings.showtype == true){&lt;br /&gt;						jmap.addTypeControl();	// Type of map Control&lt;br /&gt;					}&lt;br /&gt;					if (settings.showzoom == true &amp;&amp; settings.controlsize == "small" ){&lt;br /&gt;						jmap.addZoomShort();	// Small zoom control&lt;br /&gt;					}&lt;br /&gt;					if (settings.showzoom == true &amp;&amp; settings.controlsize == "large" ){&lt;br /&gt;						jmap.addZoomLong();		// Large zoom control&lt;br /&gt;					}&lt;br /&gt;					if (settings.showpan == true) {&lt;br /&gt;						jmap.addPanControl();	// Pan control&lt;br /&gt;					}&lt;br /&gt;					if (settings.showscale == false) {&lt;br /&gt;						/* On by default */&lt;br /&gt;						jmap.removeZoomScale();	// Show scale bars&lt;br /&gt;					}&lt;br /&gt;					if (settings.dragging == false) {&lt;br /&gt;						/* On by default */&lt;br /&gt;						jmap.disableDragMap();	// Is map draggable?&lt;br /&gt;					}&lt;br /&gt;					if (settings.scrollzoom == false) {&lt;br /&gt;						/* On by default */&lt;br /&gt;						jmap.disableKeyControls(); // Mousewheel and Keyboard control&lt;br /&gt;					}&lt;br /&gt;					break;&lt;br /&gt;					&lt;br /&gt;				case "mslive":&lt;br /&gt;					alert('Microsoft Live Maps are currently not supported but planned for version 1.4')&lt;br /&gt;					break;&lt;br /&gt;					&lt;br /&gt;				default:	&lt;br /&gt;					var jmap = this.jMap = new GMap2(this);&lt;br /&gt;					switch(settings.maptype) {&lt;br /&gt;						case "map":&lt;br /&gt;							var loadmap = G_NORMAL_MAP;&lt;br /&gt;							break;&lt;br /&gt;						case "sat":&lt;br /&gt;							var loadmap = G_SATELLITE_MAP;&lt;br /&gt;							break;&lt;br /&gt;						default:&lt;br /&gt;							var loadmap = G_HYBRID_MAP;&lt;br /&gt;							break;&lt;br /&gt;					}&lt;br /&gt;					jmap.setCenter(new GLatLng(settings.center[0],settings.center[1]),settings.zoom,loadmap);&lt;br /&gt;					switch(settings.controlsize)&lt;br /&gt;					{&lt;br /&gt;						case "small":&lt;br /&gt;							jmap.addControl(new GSmallMapControl());&lt;br /&gt;							break;&lt;br /&gt;						case "large":&lt;br /&gt;							jmap.addControl(new GLargeMapControl());&lt;br /&gt;							break;&lt;br /&gt;						case "none":&lt;br /&gt;							break;&lt;br /&gt;						default:&lt;br /&gt;							jmap.addControl(new GSmallMapControl());&lt;br /&gt;					}&lt;br /&gt;					if (settings.showtype == true){&lt;br /&gt;						jmap.addControl(new GMapTypeControl());&lt;br /&gt;					}&lt;br /&gt;					if (settings.showoverview == true){&lt;br /&gt;						jmap.addControl(new GOverviewMapControl());&lt;br /&gt;					}&lt;br /&gt;					if (settings.scrollzoom == true) {&lt;br /&gt;						/* Off by default */&lt;br /&gt;						jmap.enableScrollWheelZoom();&lt;br /&gt;					}&lt;br /&gt;					if (settings.smoothzoom == true) {&lt;br /&gt;						/* Off by default*/&lt;br /&gt;						jmap.enableContinuousZoom();&lt;br /&gt;					}&lt;br /&gt;					if (settings.dragging == false) {&lt;br /&gt;						/* On by default */&lt;br /&gt;						jmap.disableDragging();&lt;br /&gt;					}&lt;br /&gt;			}	&lt;br /&gt;			/* Seach for the lat &amp; lng of our address*/&lt;br /&gt;			jQuery(settings.searchbutton).bind('click', function(){&lt;br /&gt;				searchAddress(jmap, jQuery(settings.searchfield).attr('value'), settings);&lt;br /&gt;			});&lt;br /&gt;			/* Search for Directions */&lt;br /&gt;			jQuery(settings.directionsfind).bind("click", function(){&lt;br /&gt;				var from = $(settings.directionsfrom).attr('value');&lt;br /&gt;				var to = $(settings.directionsto).attr('value');&lt;br /&gt;				searchDirections(jmap, "from: " + from + " to: " + to, settings.directionspanel);	&lt;br /&gt;				$(settings.directionsfrom).attr('value', to);&lt;br /&gt;				$(settings.directionsto).attr('value', '');&lt;br /&gt;				return false;&lt;br /&gt;			});&lt;br /&gt;			/* On document unload, clean unload Google API*/&lt;br /&gt;			jQuery(document).unload(function(){ GUnload(); });&lt;br /&gt;		});&lt;br /&gt;		},&lt;br /&gt;	/* myMap: function()&lt;br /&gt;	 * Returns a map object from the API, so it's available to the user&lt;br /&gt;	 * Example: $().myMap().setCenter(...) for Google;&lt;br /&gt;	 * Example: $().myMap().drawZoomAndCenter(...) for Yahoo;&lt;br /&gt;	 */&lt;br /&gt;	myMap: function() {&lt;br /&gt;		return this[0].jMap;	&lt;br /&gt;	},&lt;br /&gt;	/* addPoint: function()&lt;br /&gt;	 * Returns a marker to be overlayed on the Google map&lt;br /&gt;	 * Example: $().addPoint(...);&lt;br /&gt;	 */&lt;br /&gt;	addPoint: function(pointlat, pointlng, pointhtml, isdraggable, removable) {&lt;br /&gt;		var jmap = this[0].jMap;&lt;br /&gt;		// Yahoo Maps&lt;br /&gt;		if (jmap._mapType) {			&lt;br /&gt;			var marker = new YMarker(new YGeoPoint(pointlat, pointlng));	// Create the Yahoo marker type&lt;br /&gt;			YEvent.Capture(marker, EventsList.MouseClick, function(){		// Add mouseclick to open HTML&lt;br /&gt;				marker.openSmartWindow(pointhtml);&lt;br /&gt;			});&lt;br /&gt;			// Below code does not work as expected&lt;br /&gt;			/*if (removable == true) {&lt;br /&gt;				YEvent.Capture(marker, EventsList.MouseDoubleClick, function(){&lt;br /&gt;					jmap.removeOverlay(marker);&lt;br /&gt;				});&lt;br /&gt;			}*/&lt;br /&gt;			jmap.addOverlay(marker);	// Add marker to map&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;		// Google Maps	&lt;br /&gt;		if (jmap.i.Au) {&lt;br /&gt;			var marker = new GMarker(new GLatLng(pointlat,pointlng), { draggable: isdraggable } );&lt;br /&gt;			GEvent.addListener(marker, "click", function(){&lt;br /&gt;				marker.openInfoWindowHtml(pointhtml);&lt;br /&gt;			});&lt;br /&gt;			if (removable == true) {&lt;br /&gt;				GEvent.addListener(marker, "dblclick", function(){&lt;br /&gt;					return jmap.removeOverlay(marker);&lt;br /&gt;				});&lt;br /&gt;			}&lt;br /&gt;			return jmap.addOverlay(marker);&lt;br /&gt;		}&lt;br /&gt;	},&lt;br /&gt;	/* addPoly: function(poly)&lt;br /&gt;	 * Takes an array of GLatLng points, converts it to a vector Polyline to display on the map&lt;br /&gt;	 * Example: $().addPoly(...);&lt;br /&gt;	 */&lt;br /&gt;	addPoly: function (poly, colour, width, alpha) {&lt;br /&gt;		var jmap = this[0].jMap;&lt;br /&gt;		// Yahoo Maps&lt;br /&gt;		if (jmap._mapType) {&lt;br /&gt;			return	jmap.addOverlay(poly, colour, width, alpha);&lt;br /&gt;		}&lt;br /&gt;		// Google Maps&lt;br /&gt;		if (jmap.i.Au) {&lt;br /&gt;			return jmap.addOverlay(poly);&lt;br /&gt;		}&lt;br /&gt;	},&lt;br /&gt;	/* addRss: function()&lt;br /&gt;	 * Takes a KML file and renders it to the map.&lt;br /&gt;	 * Example: $().addPoint(...);&lt;br /&gt;	 */&lt;br /&gt;	addRss: function (rssfile) {&lt;br /&gt;		var jmap = this[0].jMap;&lt;br /&gt;		// Yahoo Maps&lt;br /&gt;		if (jmap._mapType) {&lt;br /&gt;			var geoXml = new YGeoRSS(rssfile);&lt;br /&gt;			return jmap.addOverlay(geoXml);&lt;br /&gt;		}&lt;br /&gt;		// Google Maps&lt;br /&gt;		if (jmap.i.Au) {&lt;br /&gt;			var geoXml = new GGeoXml(rssfile);&lt;br /&gt;			return jmap.addOverlay(geoXml);&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;	}&lt;br /&gt;});&lt;br /&gt;})(jQuery);&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 27 Jul 2007 11:52:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4361</guid>
      <author>digitalspaghetti (Tane Piper)</author>
    </item>
    <item>
      <title>Get Google maps informations (distance and time, French version)</title>
      <link>http://snippets.dzone.com/posts/show/3964</link>
      <description>Here a little script to get time and distance between two towns with google maps. You can change "voiture" by your langage word "car", or anything else.&lt;br /&gt;&lt;br /&gt;this is a command line version : # ruby myscript.rb "Lyon" "Paris"&lt;br /&gt;You can easily change it for a Ruby on Rails project :)&lt;br /&gt;Maybie we can upgrade this script using regexp.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require "open-uri"&lt;br /&gt;require "cgi"&lt;br /&gt;&lt;br /&gt;# Command line arguments ... &lt;br /&gt;$*.each {|argu| argu.gsub!("\"","")}&lt;br /&gt;# Defaults towns&lt;br /&gt;src = "Lyon"&lt;br /&gt;dest = "Paris"&lt;br /&gt;# If we have fill two aguments ...&lt;br /&gt;if $*.size == 2 then&lt;br /&gt;        src = $*[0]&lt;br /&gt;        dest = $*[1]&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;html = ""&lt;br /&gt;url = "http://maps.google.com/maps?f=d&amp;hl=fr&amp;saddr=" + CGI.escape(src) + "&amp;daddr="+ CGI.escape(dest)&lt;br /&gt;# Read the html page&lt;br /&gt;open(url) {|f|&lt;br /&gt;        f.each_line {|line| html += line}&lt;br /&gt;}&lt;br /&gt;pos1 = html.index("voiture") # French version&lt;br /&gt;pos2 = html.index("&lt;/td&gt;",pos1) unless pos1 == nil&lt;br /&gt;pos1 = html.index("&gt;",pos2+6)+1 unless pos2 == nil&lt;br /&gt;pos2 = html.index("&lt;/td&gt;",pos2+1) -1 unless pos2 == nil&lt;br /&gt;ret = ""&lt;br /&gt;if pos1 != nil and pos2 != nil&lt;br /&gt;        ret = html[pos1..pos2].gsub!("&amp;#160;", " ")&lt;br /&gt;else&lt;br /&gt;        ret = "0"&lt;br /&gt;end&lt;br /&gt;html = nil&lt;br /&gt;p ret&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 08 May 2007 14:03:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3964</guid>
      <author>sooli (BONNAURE)</author>
    </item>
    <item>
      <title>IP Location on Google Maps</title>
      <link>http://snippets.dzone.com/posts/show/3814</link>
      <description>/*&lt;br /&gt;Example of usage:&lt;br /&gt;$ ./lip.rb snippets.dzone.com&lt;br /&gt;. Hostname: snippets.dzone.com&lt;br /&gt;. Country Code: US&lt;br /&gt;. Country Name: United States&lt;br /&gt;. Region: CA&lt;br /&gt;. Region Name: California&lt;br /&gt;. City: Los Angeles&lt;br /&gt;. Postal Code: 90017&lt;br /&gt;. Latitude: 34.0530&lt;br /&gt;. Longitude: -118.2642&lt;br /&gt;. ISP: CoreExpress&lt;br /&gt;. Organization: CoreExpress&lt;br /&gt;. Metro Code: 803&lt;br /&gt;. Area Code: 213&lt;br /&gt;. Google Maps URL: http://maps.google.com/maps?q=34.0530,+-118.2642&amp;iwloc=A&amp;hl=en&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env ruby -w&lt;br /&gt;&lt;br /&gt;if ARGV.empty?&lt;br /&gt;  puts &lt;&lt;-T&lt;br /&gt;Locate IP by haqu&lt;br /&gt;usage: ./lip.rb ip|domain ...&lt;br /&gt;  T&lt;br /&gt;  exit&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;require 'net/http'&lt;br /&gt;require 'uri'&lt;br /&gt;&lt;br /&gt;uri = URI.parse('http://www.maxmind.com/app/locate_ip')&lt;br /&gt;res = Net::HTTP.post_form(uri,&lt;br /&gt;  { 'ips' =&gt; ARGV.join(' '),&lt;br /&gt;    'type' =&gt; '', 'u' =&gt; '', 'p' =&gt; ''&lt;br /&gt;  } )&lt;br /&gt;fstr = res.body&lt;br /&gt;&lt;br /&gt;fstr.gsub!("Edition Results&lt;\/span&gt;&lt;p&gt;","CHECKPOINT")&lt;br /&gt;fstr =~ /CHECKPOINT(.+?)&lt;\/table&gt;/m&lt;br /&gt;fields = $1.grep(/&lt;(th|td)&gt;/)&lt;br /&gt;fields.each do |f|&lt;br /&gt;  f.strip!&lt;br /&gt;  f.gsub!(/&lt;[^&gt;]+&gt;/,"")&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;(0...13).each do |i|&lt;br /&gt;  puts ". #{fields[i]}: #{fields[i+13]}"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;maplink = "http://maps.google.com/maps?q=#{fields[20]},+#{fields[21]}&amp;iwloc=A&amp;hl=en"&lt;br /&gt;puts ". Google Maps URL: #{maplink}"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 14 Apr 2007 13:33:01 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3814</guid>
      <author>haqu (Sergey)</author>
    </item>
    <item>
      <title>Numeric colums for latitude / longitude in Rails 1.2 migrations</title>
      <link>http://snippets.dzone.com/posts/show/3216</link>
      <description>In Rails 1.1.6, "numeric" datatypes didn't work in migrations. This confused a lot of people who wanted to store geographic data (latitude and longitude) for use in Google Maps and the like. Floats worked, but their precision is limited -- you'll lose three or more decimal places of precision if you store the results of a typical geocoding call in a Float column. And don't even think about using strings to store your latitudes/longitudes.&lt;br /&gt;&lt;br /&gt;Fortunately, the numeric datatype problem is fixed in Rails 1.2, and you can now have do this in your migrations:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class CreatePlaces &lt; ActiveRecord::Migration&lt;br /&gt;  def self.up&lt;br /&gt;    create_table :places do |t|&lt;br /&gt;      t.column "lat", :decimal, :precision =&gt; 15, :scale =&gt; 10&lt;br /&gt;      t.column "lng", :decimal, :precision =&gt; 15, :scale =&gt; 10&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def self.down&lt;br /&gt;    drop_table :places&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;FYI, if you're stuck on Rails 1.1.6, you can use this approach:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class CreatePlaces &lt; ActiveRecord::Migration&lt;br /&gt;  def self.up&lt;br /&gt;    create_table :places do |t|&lt;br /&gt;      t.column :lat, :float &lt;br /&gt;      t.column :lng, :float&lt;br /&gt;    end&lt;br /&gt;    execute("ALTER TABLE places MODIFY lat numeric(15,10);")&lt;br /&gt;    execute("ALTER TABLE places MODIFY lng numeric(15,10);")&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def self.down&lt;br /&gt;    drop_table :places&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;... but that's ugly, database-specific (works on MySQL), and not very DRY.&lt;br /&gt;</description>
      <pubDate>Fri, 29 Dec 2006 14:36:23 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3216</guid>
      <author>alewis (Andre Lewis)</author>
    </item>
    <item>
      <title>Draggable eInsert</title>
      <link>http://snippets.dzone.com/posts/show/2463</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;    //&lt;![CDATA[&lt;br /&gt;    &lt;br /&gt;    if (GBrowserIsCompatible()) { &lt;br /&gt;&lt;br /&gt;      var map = new GMap2(document.getElementById("map"));&lt;br /&gt;      map.addControl(new GLargeMapControl());&lt;br /&gt;      map.addControl(new GMapTypeControl());&lt;br /&gt;      map.setCenter(new GLatLng(53.849, -3.022),16);&lt;br /&gt;&lt;br /&gt;      // Optionally set the cursors to be used for dragging&lt;br /&gt;      GDraggableObject.setDraggableCursor("move");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      // Insert the "Nosuch Road" road &lt;br /&gt;      var insert1 = new EInsert(new GLatLng(53.85022, -3.01772), "nosuch.png", new GSize(145,233), 16);&lt;br /&gt;      map.addOverlay(insert1);&lt;br /&gt;      // Make it draggable&lt;br /&gt;      insert1.makeDraggable();&lt;br /&gt;      &lt;br /&gt;      // A new event that returns the new latlng when the drag ends&lt;br /&gt;      GEvent.addListener(insert1, "dragend", function (pt) {&lt;br /&gt;        GLog.write("New position of insert = "+ pt.lat() + ","+pt.lng());&lt;br /&gt;      });&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    //]]&gt;&lt;br /&gt;    &lt;/script&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 24 Aug 2006 06:34:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2463</guid>
      <author>NickH (Nicolas Haase)</author>
    </item>
    <item>
      <title>Using Google Maps EZ</title>
      <link>http://snippets.dzone.com/posts/show/564</link>
      <description>Chris Houser writes an easy HTML API for Google Maps.&lt;br /&gt;Here's the simplest example&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;html&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;  &lt;script src="http://maps.google.com/maps?file=api&amp;v=1&amp;key=yourgmapskey"&gt;&lt;/script&gt;&lt;br /&gt;  &lt;script src="http://bluweb.com/chouser/gmapez/gmapez.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;/head&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;&lt;br /&gt;  &lt;div class="GMapEZ" style="width: 300px; height: 300px;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;See more examples here&lt;br /&gt;http://bluweb.com/us/chouser/gmapez/docs.html</description>
      <pubDate>Sun, 07 Aug 2005 12:53:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/564</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
