I'm making a java app desktop and I need to put in a form a map. Searching online I found that I can show google map with javascript. This is the code named map.html
:
<!DOCTYPE html><html><head>
<title>City Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style></head><body><div id="map"></div><script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {
lat: -34.397,
lng: 150.644},
zoom: 8
});
}</script><script src="myAPI KEY" async defer></script></body></html>
I want to put this map inside a Jpanel, but I don't find a solution to do this. Java GUI code:
public class Login {
private JPanel panel1;
private JButton button1;
public static void main(String argv[]){
JFrame pannello = new JFrame("map.html");
pannello.setContentPane(new Login().panel1);
pannello.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pannello.pack();
pannello.setVisible(true);
}}
Someone can help me? Thanks
P.S. I don't know if it's the best solution to show a google map