hallo,
ich lasse mit folgenden text einen kleinen kartenausschnitt aus google maps in 300x300 frame ausgeben...
public class GoogleMapsDemo {
public static void main(String[] args) throws IOException {
JFrame test = new JFrame("Google Maps");
try {
String latitude = "47.044115";
String longitude = "11.098889";
String imageUrl = "https://maps.googleapis.com/maps/api/staticmap?center="
+ latitude
+ ","
+ longitude
+ "&zoom=11&size=400x400&scale=2&maptype=roadmap";
// + "&zoom=11&size=612x612&scale=2&maptype=roadmap";
String destinationFile = "image.jpg";
// read the map image from Google
// then save it to a local file: image.jpg
//
URL url = new URL(imageUrl);
InputStream is = url.openStream();
OutputStream os = new FileOutputStream(destinationFile);
byte[] b = new byte[2048];
int length;
while ((length = is.read(b)) != -1) {
os.write(b, 0, length);
}
is.close();
os.close();
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
// create a GUI component that loads the image: image.jpg
//
ImageIcon imageIcon = new ImageIcon((new ImageIcon("image.jpg"))
.getImage().getScaledInstance(300, 300,
java.awt.Image.SCALE_SMOOTH));
test.add(new JLabel(imageIcon));
// show the GUI window
test.setVisible(true);
test.pack();
}
...
funktioniert ganz gut, nur möchte ich gerne auf meine koordinaten einen marker setzen wie es auch in google earth aussieht.
falls jemand eine einfache lösung hat, vielen dank dafür,
ich möchte nicht erst irgendwelche programme für geld runter laden
danke
Tino
ich lasse mit folgenden text einen kleinen kartenausschnitt aus google maps in 300x300 frame ausgeben...
public class GoogleMapsDemo {
public static void main(String[] args) throws IOException {
JFrame test = new JFrame("Google Maps");
try {
String latitude = "47.044115";
String longitude = "11.098889";
String imageUrl = "https://maps.googleapis.com/maps/api/staticmap?center="
+ latitude
+ ","
+ longitude
+ "&zoom=11&size=400x400&scale=2&maptype=roadmap";
// + "&zoom=11&size=612x612&scale=2&maptype=roadmap";
String destinationFile = "image.jpg";
// read the map image from Google
// then save it to a local file: image.jpg
//
URL url = new URL(imageUrl);
InputStream is = url.openStream();
OutputStream os = new FileOutputStream(destinationFile);
byte[] b = new byte[2048];
int length;
while ((length = is.read(b)) != -1) {
os.write(b, 0, length);
}
is.close();
os.close();
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
// create a GUI component that loads the image: image.jpg
//
ImageIcon imageIcon = new ImageIcon((new ImageIcon("image.jpg"))
.getImage().getScaledInstance(300, 300,
java.awt.Image.SCALE_SMOOTH));
test.add(new JLabel(imageIcon));
// show the GUI window
test.setVisible(true);
test.pack();
}
...
funktioniert ganz gut, nur möchte ich gerne auf meine koordinaten einen marker setzen wie es auch in google earth aussieht.
falls jemand eine einfache lösung hat, vielen dank dafür,
ich möchte nicht erst irgendwelche programme für geld runter laden
danke
Tino