Posted by: surikov on: April 25, 2009

Use red controls for zoom/rotate.
Drag map by mouse to change location.
Open WalkMap in new window.
Application stores last location point in <Home>/WalkMap.properties.xml (for Vista this file is C:\Users\<user>\WalkMap.properties.xm).
package walkmap;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.scene.effect.*;
import javafx.scene.input.*;
import javafx.scene.text.*;
import crudfx.map.*;
import crudfx.data.*;
import crudfx.util.*;
var plus:Rectangle;
var minus:Rectangle;
var properties:HomeProperties=HomeProperties{ key:"WalkMap.properties.xml" };
FX.addShutdownAction(
function():Void{
properties.gather();
properties.save();
}
);
def _zoom=properties.node("map").node("zoom").asNumber(8);
def _latitude=properties.node("map").node("latitude").asNumber(56.35555648803711);
def _longitude=properties.node("map").node("longitude").asNumber(-316.0292053222656);
var zoom:Number=bind _zoom.value with inverse;
var latitude:Number=bind _latitude.value with inverse;
var longitude:Number=bind _longitude.value with inverse;
Stage{
title:"WalkMap"
width:500
height:500
scene:Scene{
content:[
GoogleMap{
width:500
height:500
zoom:bind zoom
latitude:bind latitude with inverse;
longitude:bind longitude with inverse;
}
,Group{
effect:DropShadow{
offsetY:2
offsetX:2
color:Color.web("#666666")
}
content:[
Rectangle{width:11 height:5 y:14+9 x:150-22+16+6 fill:Color.web("#ff0000")}
,Rectangle{width:5 height:11 y:14+6 x:150-22+16+9 fill:Color.web("#ff0000")}
,plus=Rectangle{
x:150-22+16
y:14
width:22
height:22
arcWidth:22
arcHeight:22
fill:bind if (plus.hover) then Color.web("#ffffff",0.9) else Color.web("#ffffff",0.5)
stroke:Color.web("#ff0000",0.5)
strokeWidth:3
blocksMouse:true
cursor:Cursor.HAND
onMouseClicked:function(e:MouseEvent):Void{
if(zoom<16)zoom=zoom+1;
}
}
,Rectangle{width:11 height:5 y:14+9 x:150-22+16+32+6 fill:Color.web("#ff0000")}
,minus=Rectangle{
x:150-22+16+32
y:14
width:22
height:22
arcWidth:22
arcHeight:22
fill:bind if (minus.hover) then Color.web("#ffffff",0.9) else Color.web("#ffffff",0.5)
stroke:Color.web("#ff0000",0.5)
strokeWidth:3
blocksMouse:true
cursor:Cursor.HAND
onMouseClicked:function(e:MouseEvent):Void{
if(zoom>0)zoom=zoom-1;
}
}
Rectangle{
x:-22
y:14
width:150
height:22
arcWidth:22
arcHeight:22
fill:Color.web("#ffffff")
stroke:Color.web("#ff0000",0.5)
strokeWidth:3
blocksMouse:true
}
]
}
,Text{
font:Font{
size:12
}
x:10
y:30
content:Tools.getVersion()
}
]
}
}
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.scene.effect.*;
import javafx.scene.input.*;
import javafx.scene.text.*;
import crudfx.map.*;
import crudfx.data.*;
import crudfx.util.*;
var plus:Rectangle;
var minus:Rectangle;
var properties:HomeProperties=HomeProperties{ key:”WalkMap.properties.xml” };
FX.addShutdownAction(
function():Void{
properties.gather();
properties.save();
}
);
def _zoom=properties.node(“map”).node(“zoom”).asNumber(8);
def _latitude=properties.node(“map”).node(“latitude”).asNumber(56.35555648803711);
def _longitude=properties.node(“map”).node(“longitude”).asNumber(-316.0292053222656);
var zoom:Number=bind _zoom.value with inverse;
var latitude:Number=bind _latitude.value with inverse;
var longitude:Number=bind _longitude.value with inverse;
Stage{
title:”WalkMap”
width:500
height:500
scene:Scene{
content:[
GoogleMap{
width:500
height:500
zoom:bind zoom
latitude:bind latitude with inverse;
longitude:bind longitude with inverse;
}
,Group{
effect:DropShadow{
offsetY:2
offsetX:2
color:Color.web("#666666")
}
content:[
Rectangle{width:11 height:5 y:14+9 x:150-22+16+6 fill:Color.web("#ff0000")}
,Rectangle{width:5 height:11 y:14+6 x:150-22+16+9 fill:Color.web("#ff0000")}
,plus=Rectangle{
x:150-22+16
y:14
width:22
height:22
arcWidth:22
arcHeight:22
fill:bind if (plus.hover) then Color.web("#ffffff",0.9) else Color.web("#ffffff",0.5)
stroke:Color.web("#ff0000",0.5)
strokeWidth:3
blocksMouse:true
cursor:Cursor.HAND
onMouseClicked:function(e:MouseEvent):Void{
if(zoom<16)zoom=zoom+1;
}
}
,Rectangle{width:11 height:5 y:14+9 x:150-22+16+32+6 fill:Color.web("#ff0000")}
,minus=Rectangle{
x:150-22+16+32
y:14
width:22
height:22
arcWidth:22
arcHeight:22
fill:bind if (minus.hover) then Color.web("#ffffff",0.9) else Color.web("#ffffff",0.5)
stroke:Color.web("#ff0000",0.5)
strokeWidth:3
blocksMouse:true
cursor:Cursor.HAND
onMouseClicked:function(e:MouseEvent):Void{
if(zoom>0)zoom=zoom-1;
}
}
Rectangle{
x:-22
y:14
width:150
height:22
arcWidth:22
arcHeight:22
fill:Color.web("#ffffff")
stroke:Color.web("#ff0000",0.5)
strokeWidth:3
blocksMouse:true
}
]
}
,Text{
font:Font{
size:12
}
x:10
y:30
content:Tools.getVersion()
}
]
}
}
[...] JavaFX & Google Map Posted April 25, 2009 [...]
Yeah! share! Your site is in russian and I suck at that
[...] hoping that it will shape up well for the competition, but I’m seeing some really good programs being made with Java FX so far! This is going to be [...]
too bad it doesnt work on MAC
Did not work for me. Shows gray background (I am on windows). I guess I am happy with Flash or Ajax maps for now
)
Sorry, now Google restricts use maps in desktop applications. I will publish map example from Yahoo maps later.
Great post, make more
Interesting application. I’m on windows XP home ed. and had no problem with it. Loading took quite long, but had no problem in navigating from Russia to my home town in New zealand and drill down to my home section details.
wow that nicely writted simplified code. i have one too but that too big.
thanx
Keep the good posts comming:)
Really nice post. I get your point:)
I’m can’t agree with all of it, but for det most parts i think it’s a really god post..
Nice articel… please keep them comming.
A lot of good argument:) nice work..
Keep up the good hard work man, this article has really blown me away ! Good stuff, recommended.
1 | Sujit
April 25, 2009 at 12:11 pm
Can you please pass the way we can integrate google map in Java FX