Bir Java uygulamasından google maps API'ye nasıl erişirsiniz?Java uygulamasında google maps api'ye nasıl erişilir?
cevap
İstemci tarafında Java için en iyi bahsiniz Static Maps API olacaktır. Sunucu tarafı Java için, yanıt, geliştirme için kullandığınız çerçeveye büyük ölçüde bağlı olacaktır. Bunu söyledikten sonra, Google Haritalar API'sı is well documented.
Eğer SwingX gelen Salıncak Labs, JXMapKit kullanabilirsiniz: http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html
Oldukça yalındır. Daha fazla bilgi için web sitesine bakınız.
JXMapKit mapView = new JXMapKit();
mapView.setDefaultProvider(DefaultProviders.OpenStreetMaps);
mapView.setDataProviderCreditShown(true);
add(mapView)
Bu gibi görünecektir:
alt text http://today.java.net/images/2007/10/basic_running_app.png
kod üç satır ile, yukarıdaki makalede kaynak koduna bir göz atın, kolayca bir harita görüntüleyebilirsiniz:
Swing-WS, JXMapViewer bileşeni kullanılabilir ve JavaScript sürümü ile benzer işlevler sağlar. Bununla birlikte, sağlanan API'ların dışındaki Google kiremit sunucularına erişmek hala yasal değildir: JavaScript ve Flash.
Bu isteği takip etmek için bir sorun var: http://code.google.com/p/gmaps-api-issues/issues/detail?id=1396. Onaylandı, ancak ne zaman müsait olacağını kim bilebilir? Eğer sadece bir statik harita arıyorsanız
harita çalışma almak için bu kodu kullanabilirsiniz:
import java.awt.BorderLayout;
public class GoogleMapsGui extends JFrame {
final Logger log = Logger.getLogger(GoogleMapsGui.class.getName());
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
GoogleMapsGui frame = new GoogleMapsGui();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public GoogleMapsGui() {
setTitle("Map");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 592, 352);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JFrame test = new JFrame("Google Maps");
try {
// String latitude = "-25.9994652";
// String longitude = "28.3112051";
String location = JOptionPane
.showInputDialog(" please enter the desired loccation");// get
// the
// location
// for
// geo
// coding
Scanner sc = new Scanner(location);
Scanner sc2 = new Scanner(location);
String marker = "";
String path = JOptionPane
.showInputDialog("what is your destination?");
String zoom = JOptionPane
.showInputDialog("how far in do you want to zoom?\n"
+ "12(zoomed out) - 20 (zoomed in)");
String imageUrl = "https://maps.googleapis.com/maps/api/staticmap?";
while (sc.hasNext()) {// add location to imageUrl
imageUrl = imageUrl + sc.next();
}
marker = "&markers=color:red|";
while (sc2.hasNext()) {// add marker location to marker
marker = marker + sc2.next() + ",";
}
marker = marker.substring(0, marker.length() - 1);
imageUrl = imageUrl + "&size=620x620&scale=2&maptype=hybrid"
+ marker;
//
log.info("Generated url");
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);
}
log.info("Created image.jpg");
is.close();
os.close();
sc.close();
sc2.close();
log.info("Closed util's");
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
log.severe("Could not create image.jpg");
}// fin getting and storing image
ImageIcon imageIcon = new ImageIcon((new ImageIcon("image.jpg"))
.getImage().getScaledInstance(630, 600,
java.awt.Image.SCALE_SMOOTH));
contentPane.setLayout(null);
JLabel imgMap = new JLabel(imageIcon);
imgMap.setBounds(5, 5, 571, 308);
contentPane.add(imgMap);
}
}
da goolge statik haritalar API kontrol here
- 1. Java masaüstü uygulamasında google maps embed
- 2. nodejs uygulamasında Google Maps geometri kütüphanesini kullanma
- 3. Google Maps Polyline - Nasıl kaldırırım?
- 4. Haritalarımın jQuery Mobile/Google Maps API3 uygulamasında neden merkezileştiriyorsunuz?
- 5. Bir Google Maps InfoWindow
- 6. Android Google Maps v2 -
- 7. Android - Google Maps yönlendirme
- 8. ColdFusion'da Java Enum'a nasıl erişilir?
- 9. Google Maps API (statik)
- 10. Google Maps V2 MapView
- 11. laravel projesinde google maps
- 12. Google Maps: Google Maps V3 ve ben kullanıyorum
- 13. Android Google Maps ClassNotFoundException
- 14. Google Maps v3 - mil
- 15. Google Maps API ile Google Maps Engine arasında mı?
- 16. google maps v3
- 17. Google Static Maps API:
- 18. Google Maps url
- 19. google maps api
- 20. Google Maps Kabarcık Şablonları
- 21. Google Maps ve DART
- 22. Google Maps görünmüyor
- 23. Google, Google Maps Street View In
- 24. google maps. Bir merkez noktası
- 25. Ekran konumu Koordinatlar - Google Maps
- 26. Google maps api Çember eğimi?
- 27. Google maps - Posta kodu hazırlama
- 28. google maps: doğrudan google sunucusunda kullan?
- 29. google-maps kml, çizgi dizgisi nasıl etiketlenir?
- 30. Webpack Google Maps API ile nasıl kullanılır?