zoukankan      html  css  js  c++  java
  • 在线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

  • 相关阅读:
    阿里云ssh断开处理办法
    OSSIM安装使用教程(OSSIM-5.6.5)
    MySQL字符串列与整数比较
    Linux获取so/ko文件版本号教程
    Linux服务器后门自动化查杀教程
    最强半自动化抓鸡工具打造思路
    渗透测试报告中的那些名词解释
    ELK+MySQL出现大量重复记录问题处理
    Python3+SQLAlchemy不使用字段名获取主键值教程
    Python3+SQLAlchemy+Sqlite3实现ORM教程
  • 原文地址:https://www.cnblogs.com/yony/p/2944267.html
Copyright © 2011-2022 走看看