Java 애플리케이션에서 Google Maps API에 어떻게 액세스합니까?Java 응용 프로그램에서 google maps api에 액세스하는 방법?
답변
클라이언트 측 Java에 대한 가장 좋은 방법은 Static Maps API입니다. 서버 측 Java의 경우 대답은 개발을 위해 사용중인 프레임 워크에 크게 의존합니다. 그런 말로하면 Google Maps API is well documented입니다.
당신은 swingx에서 스윙 랩, JXMapKit를 사용할 수 있습니다 http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html
그것은 꽤 똑바로 앞으로이다. 자세한 정보는 웹 사이트를 참조하십시오.
JXMapKit mapView = new JXMapKit();
mapView.setDefaultProvider(DefaultProviders.OpenStreetMaps);
mapView.setDataProviderCreditShown(true);
add(mapView)
그것은 다음과 같이 표시됩니다
alt text http://today.java.net/images/2007/10/basic_running_app.png
코드의 세 가지 라인으로, 위의 문서의 소스 코드를보세요, 당신은 쉽게지도를 볼 수 있습니다
Swing-WS을 사용할 수 있으며 JXMapViewer 구성 요소를 사용할 수 있으며 JavaScript 버전과 유사한 기능을 제공합니다. 그러나 제공된 API (JavaScript 및 Flash) 이외의 Google 타일 서버에 액세스하는 것은 아직 유효하지 않습니다.
이 요청을 추적하기 위해 열어 본 이슈가 있습니다 (http://code.google.com/p/gmaps-api-issues/issues/detail?id=1396). 승인되었지만 누가 언제 사용할 수 있는지 알 수 있습니다. 당신은 그냥 정적지도를 찾고 있다면
당신은지도 작업 얻기 위해이 코드를 사용할 수 있습니다
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);
}
}
또한 사용하여 Goolge 정적지도 API를 체크 아웃을 here
- 1. Java : Google Maps alternative
- 2. C++ 응용 프로그램에서 Java 메서드에 액세스하는 방법
- 3. Bing지도 타일을 Google Maps API에 통합
- 4. Google Maps 용 Java API
- 5. Java 웹 응용 프로그램에서 WEB-INF에있는 파일에 액세스하는 방법
- 6. Google Maps Geocoder 요청
- 7. Google Maps Data API와 Google Maps API
- 8. ArcGIS Server + Google Maps API에 KMZ 파일 표시
- 9. v3 Google Maps Geocoding API에 정확도를 나타내는 필드가 있습니까?
- 10. ASP.NET 응용 프로그램에서 데이터베이스에 액세스하는 방법?
- 11. 다른 C# 응용 프로그램에서 컨트롤에 액세스하는 방법?
- 12. C# 응용 프로그램에서 이진 리소스에 액세스하는 방법
- 13. 다른 응용 프로그램에서 LinqToSqlcCasses에 액세스하는 방법
- 14. iphone 응용 프로그램에서 지불 게이트웨이에 액세스하는 방법
- 15. 플렉스 Flashbuilder Google Maps
- 16. 응용 프로그램에서 액세스하는 파일 이름
- 17. MapActivity (Google Maps API)의 Google Maps 고급 기능
- 18. VB.NET 응용 프로그램에서 Google 검색을 사용하는 방법?
- 19. Grails + Google Maps API
- 20. 웹 응용 프로그램에서 프로그래밍 방식으로 oracle 10g OLAP에 액세스하는 방법
- 21. Flex와 함께 Google 검색 API에 액세스하는 데 어려움이 있습니다.
- 22. 타사 응용 프로그램을 통해 salesforce API에 액세스하는 방법은 무엇입니까?
- 23. android google maps issue
- 24. Google maps javascript issue
- 25. Infowindow with Google maps
- 26. Google maps 다각형 질문
- 27. Google Maps Bubble Templates
- 28. 아이폰 : google maps directions
- 29. backbone.js와 google maps 사용
- 30. google maps api