• 在线Google Map在swing中的应用


    引用:http://hi.baidu.com/newjavaee/item/3be4f32060eb8b102a0f1cb4

    一个小东西,C/S程序中调用在线google map。

    不过需要用到一种技术,DJ NativeSwing 一个开源框架,很好用的。

    demo如下:

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package newgpsclientui;
    import chrriis.common.UIUtils;
    import chrriis.dj.nativeswing.swtimpl.NativeInterface;
    import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;
    import java.awt.BorderLayout;
    import java.net.URL;
    import javax.swing.*;
    public class TestMap {   
      
      public static JComponent createContent() {   
        JWebBrowser webBrowser = new JWebBrowser();   
        webBrowser.setBarsVisible(false);   
        URL path =WebBrowserFunctionExample.class.getResource("/");
        String script1 ="<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\" type=\"text/javascript\"></script>";
        String script2="<script type=\"text/javascript\" src=\""+path+"google/markerwithlabel.js\"></script>";
        String script3="<script type=\"text/javascript\" src=\""+path+"google/infobubble.js\"></script>";
        String script4="<script type=\"text/javascript\" src=\""+path+"google/google_map.js\"></script> ";
        String jquery = "<script type=\"text/javascript\" src=\""+path+"js/jquery.js\"></script>";
        String script5="<head><style type=\"text/css\">#mapbar{ height:100%;100%;}</style></head>";
        String script6="<script type=\"text/javascript\">$(document).ready(function(){ initMap();});</script>";
        String div ="<body ><div id=\"mapbar\"></div></body>";
        System.out.println(script1+script2+script3+script4+script5+div);
        webBrowser.setHTMLContent(jquery+script1+script2+script3+script4+script5+div+script6); 
        return webBrowser;   
      }   
      
      /* Standard main method to try that test as a standalone application. */  
      public static void main(String[] args) {   
        NativeInterface.open();   
        UIUtils.setPreferredLookAndFeel();   
        SwingUtilities.invokeLater(new Runnable() {   
          public void run() {   
            JFrame frame = new JFrame("DJ Native Swing Test");   
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   
            frame.getContentPane().add(createContent(), BorderLayout.CENTER);   
            frame.setSize(800, 600);   
            frame.setLocationByPlatform(true);   
            frame.setVisible(true);   
          }   
        });   
        NativeInterface.runEventPump();   
      }   
      
    } 

     运行效果如图:swing中引入Google Map

  • 相关阅读:
    安装go版本
    golang简介
    安装MySQL
    art.dialog.art 中,将子页面窗口中的值传递给父框架中
    Windows7下安装CentOS
    生成uuid
    如何开启win7端口的图文教程
    PHPMailer不能发送邮件
    sql 如果关联表 没有值 设置 默认值
    php array 分页
  • 原文地址:https://www.cnblogs.com/yony/p/2944267.html
Copyright © 2020-2023  润新知