Google Maps used from a Groovy SwingBuilder
7
Using the SwingX JXMapViewer and using a special tile factory to retrieve Google Maps tiles, from a Groovy SwingBuilder.
import java.awt.*
import java.awt.BorderLayout as BL
import javax.swing.WindowConstants as WC
import org.jdesktop.swingx.mapviewer.*
import org.jdesktop.swingx.JXMapViewer
import groovy.swing.SwingBuilder
def mapViewer = new JXMapViewer()
def tfi = new TileFactoryInfo(0, 20, 17, 256, true, true, "http://mt.google.com/mt?w=2.43", "x", "y", "zoom")
mapViewer.tileFactory = new DefaultTileFactory(tfi)
mapViewer.zoom = 9
mapViewer.centerPosition = [43.835, 2.329]
mapViewer.preferredSize = [800, 600]
frame = new SwingBuilder().frame(title: 'Groovy Maps', defaultCloseOperation: WC.DISPOSE_ON_CLOSE) {
panel(layout: new BL()) {
panel(constraints: BL.CENTER) { widget(mapViewer) }
panel(constraints: BL.SOUTH) {
button(text: "+", actionPerformed: { mapViewer.zoom -= 1 })
button(text: "-", actionPerformed: { mapViewer.zoom += 1 })
}
}
}
frame.pack()
frame.visible = true
Comments
Wed. Jun. 6th, 2007 3:43 PM
tom_zeng
tom_zeng





