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

  • 相关阅读:
    使用Jquery Mobile设计Android通讯录
    jQuery Mobile中文手册:开发入门
    分享15款为jQuery Mobile定制的插件
    18个jQuery Mobile开发贴士和教程
    关于altera fpga的io时序优化问题
    关于simulink hdlcoder的优化问题
    关于matlab中定点数overflow的处理办法
    跨时钟域问题(转载)
    matlab中卷积编码参数的理解
    ft,dtft,dft的关系(转载)
  • 原文地址:https://www.cnblogs.com/yony/p/2944267.html
Copyright © 2011-2022 走看看