Java Reference
In-Depth Information
}
}
onDone:function(){
http.stop();
}
}
http.start();
}
5. The next segment lists function
getGMap()
which retrieves a static map image for
a given address. This is the same code used in the previous recipe
Downloading
images with HttpRequest
. So, it will be abbreviated, if you need more details on
how to download images using
HttpRequest
, see the aforementioned recipe.
function
getGMap
(addr:Address){
var loc = "{addr.street}, {addr.city} {addr.state} {addr.
zip}";
var url = bind "{GOOGLE_WS}?"
"center={conv.encodeString(loc)}"
"&zoom=13"
"&size={imgW as Integer}x{imgH as Integer}"
"&maptype=map"
"&format=png32"
"&markers=color:blue|{conv.encodeString(loc)}"
"&sensor=false"
"&key={GOOGLE_KEY}";
var
http:HttpRequest
= HttpRequest {
location: url;
onInput
: function(is: java.io.InputStream) {
try {
if(is.available() > 0) {
var buffImg = ImageIO.read(is);
imgView.image = SwingUtils.toFXImage(buffImg);
}
} finally {
is.close();
}
}
...
};
http.start();
}

