World Wind Java开发之十一——加载热点信息(仿Google Earth)(转)
在GE的图层中有一个照片图层,在浏览时可以看到各地的一些图片,我们称之为热点信息,如下图所示:

再来看下本文的实现效果:
效果是不是很像呢,其实实现这个很简单,参照examples中的Balloons就可以很容易的实现,这里我自己封装了BalloonUtil类便于复用,代码很简单都加了注释就不再一一展开了,直接附上源代码,有看不明白的地方可以留言交流哈。
- /**
- * @Copyright 2014-2020 @��˶
- **/
- package edu.whu.vge.util;
- import gov.nasa.worldwind.avlist.AVKey;
- import gov.nasa.worldwind.awt.WorldWindowGLCanvas;
- import gov.nasa.worldwind.geom.Position;
- import gov.nasa.worldwind.layers.RenderableLayer;
- import gov.nasa.worldwind.render.AbstractBrowserBalloon;
- import gov.nasa.worldwind.render.BalloonAttributes;
- import gov.nasa.worldwind.render.BasicBalloonAttributes;
- import gov.nasa.worldwind.render.GlobeBrowserBalloon;
- import gov.nasa.worldwind.render.PointPlacemark;
- import gov.nasa.worldwind.render.Size;
- import gov.nasa.worldwind.util.Logging;
- import gov.nasa.worldwind.util.WWIO;
- import gov.nasa.worldwindx.examples.util.BalloonController;
- import gov.nasa.worldwindx.examples.util.HotSpotController;
- import java.io.InputStream;
- /**
- *
- * @项目名称:SMartScope
- * @类名称:BalloonsUtil
- * @类描述:
- * @创建人:刘硕
- * @创建时间:2015年2月3日 下午4:56:26
- * @修改备注:
- * @版本:
- */
- public class BalloonsUtil
- {
- private double balloonLat; // 气球纬度
- private double balloonLon; // 气球经度
- private String balloonContentPath; // html文件路径
- private String balloonName; // 气球名称
- protected HotSpotController hotSpotController;
- protected BalloonController balloonController;
- /**
- *
- * 创建一个新的实例 BalloonsUtil.
- *
- * @param balloonLat
- * @param balloonLon
- * @param balloonContentPath
- * @param balloonName
- */
- public BalloonsUtil(double balloonLat, double balloonLon,
- String balloonContentPath, String balloonName)
- {
- super();
- this.balloonLat = balloonLat;
- this.balloonLon = balloonLon;
- this.balloonContentPath = balloonContentPath;
- this.balloonName = balloonName;
- }
- /**
- * s
- *
- * @方法名称: makeBrowserBalloon ;
- * @方法描述: 生成Balloon标记图层 ;
- * @参数 :@param windowGLCanvas
- * @参数 :@return
- * @返回类型: RenderableLayer ;
- * @创建人:刘硕;
- * @创建时间:2015年2月3日 下午5:01:03;
- * @throws
- */
- public RenderableLayer makeBrowserBalloon(WorldWindowGLCanvas windowGLCanvas)
- {
- // ע��balloonController
- this.hotSpotController = new HotSpotController(windowGLCanvas);
- this.balloonController = new BalloonController(windowGLCanvas);
- RenderableLayer layer = new RenderableLayer();
- layer.setName(balloonName);
- String htmlString = null;
- InputStream contentStream = null;
- try
- {
- // 读取html文件内容
- contentStream = WWIO.openFileOrResourceStream(balloonContentPath,
- null);
- htmlString = WWIO.readStreamToString(contentStream, null);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- finally
- {
- WWIO.closeStream(contentStream, balloonContentPath);
- }
- if (htmlString == null) htmlString = Logging.getMessage(
- "generic.ExceptionAttemptingToReadFile", balloonContentPath);
- // 创建一个GlobeBrowserBalloon
- Position balloonPosition = Position.fromDegrees(balloonLat, balloonLon);
- AbstractBrowserBalloon balloon = new GlobeBrowserBalloon(htmlString,
- balloonPosition);
- // 设置GlobeBrowserBalloon属性
- BalloonAttributes attrs = new BasicBalloonAttributes();
- attrs.setSize(new Size(Size.NATIVE_DIMENSION, 0d, null,
- Size.NATIVE_DIMENSION, 0d, null));
- balloon.setAttributes(attrs);
- // 将GlobeBrowserBalloon与PointPlacemark关联起来
- PointPlacemark placemark = new PointPlacemark(balloonPosition);
- placemark.setLabelText(balloonName);
- placemark.setValue(AVKey.BALLOON, balloon);
- layer.addRenderable(balloon);
- layer.addRenderable(placemark);
- return layer;
- }
- public double getBalloonLat()
- {
- return balloonLat;
- }
- public void setBalloonLat(double balloonLat)
- {
- this.balloonLat = balloonLat;
- }
- public double getBalloonLon()
- {
- return balloonLon;
- }
- public void setBalloonLon(double balloonLon)
- {
- this.balloonLon = balloonLon;
- }
- public String getBalloonContentPath()
- {
- return balloonContentPath;
- }
- public void setBalloonContentPath(String balloonContentPath)
- {
- this.balloonContentPath = balloonContentPath;
- }
- public String getBalloonName()
- {
- return balloonName;
- }
- public void setBalloonName(String balloonName)
- {
- this.balloonName = balloonName;
- }
- }
调用的时候,只需键入以下代码即可:
- String htmlPath = System.getProperty("user.dir")
- + "\\src\\edu\\whu\\vge\\data\\whu.html";
- BalloonsUtil balloonsUtil = new BalloonsUtil(30.5271,
- 114.3604, htmlPath, "我在这里");
- wwPanel.getWorldWindowGLCanvas()
- .getModel()
- .getLayers()
- .add(balloonsUtil.makeBrowserBalloon(wwPanel
- .getWorldWindowGLCanvas()));
另外,附上whu.html网页的代码以供大家参考。
- <html>
- <head>
- <style type='text/css'>
- html, body {
- margin: 0 0;
- width: 100%;
- height: 100%;
- overflow: hidden
- }
- a:link {
- color: #0000CD;
- text-decoration: underline
- }
- table {
- font-family: verdana, 黑体, sans-serif;
- font-size: 12px;
- color: #4169E1;
- border-width: 1px;
- border-color: #a9c6c9;
- border-collapse: collapse
- }
- th {
- background-color: #4169E1;
- color: #fff
- }
- tr {
- background-color: #d4e3e5
- }
- td {
- border-width: 1px;
- border-style: solid;
- border-color: #a9c6c9
- }
- </style>
- <title></title>
- </head>
- <body>
- <table border='0'>
- <tr>
- <th align='center' colspan='2'>武汉大学</th>
- </tr>
- <tr>
- <td rowspan='7'><a href="http://www.whu.edu.cn/index.htm"> <img
- border='0' alt='' width='300px' height='225px'
- src='http://news.whu.edu.cn/_mediafile/whu_news/2015/02/02/1eq0euop1q.jpg'>
- </a></td>
- </tr>
- </table>
- </body>
- </html>
World Wind Java开发之十一——加载热点信息(仿Google Earth)(转)的更多相关文章
- World Wind Java开发之十三——加载Geoserver发布的WMS服务(转)
这篇是转载的平常心博客,原地址见:http://www.v5cn.cn/?p=171 1.WMSTiledImageLayer类说明 一个WMSTiledImageLayer类对象只能对应一个WMS发 ...
- World Wind Java开发之六——解析shape文件(转)
http://blog.csdn.net/giser_whu/article/details/41647117 最近一直忙于导师项目的事情了,几天没更新了,昨天和今天研究了下WWJ解析shp文件的源代 ...
- [转]World Wind Java开发之四——搭建本地WMS服务器
在提供地理信息系统客户端时,NASA还为用户提供了开源的WMS Server 服务器应用:World Wind WMS Server.利用这个应用,我们可以架设自己的WMS服务并使用自己的数据(也支持 ...
- java在windows下加载dll
java在类中加载动态链接库文件. 类文件中: static { System.loadLibrary("dll文件"); } dll文件在工程的包路径下.例如:pro/bin/h ...
- 混合开发(一)——WebView开发高级技巧之加载网页以及JavaScript,加载进度条
混合开发(一)--WebView开发高级技巧之加载网页以及JavaScript,加载进度条 现在关于混合开发也越来越多了,很多人喜欢跟随,比如HB,比如RN,其实这东西很早就有这么一个概念了,而且说实 ...
- Java类编译、加载、和执行机制
Java类编译.加载.和执行机制 标签: java 类加载 类编译 类执行 机制 0.前言 个人认为,对于JVM的理解,主要是两大方面内容: Java类的编译.加载和执行. JVM的内存管理和垃圾回收 ...
- 【记录】尝试用QEMU模拟ARM开发板去加载并运行Uboot,kernel,rootfs【转】
转自:https://www.crifan.com/try_use_qemu_emulate_arm_board_to_load_and_run_uboot_kernel_rootfs/ [背景] 手 ...
- 微信小程序开发动感十足的加载动画--都在这里!
代码地址如下:http://www.demodashi.com/demo/14242.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...
- java——Class、动态加载
Class和Object混淆了? Object: 任何类都是Object类的子类 Class: 任何类都是Class的实例对象 Class可以说是一种特殊的类,它表示的是类类型,Object仍然是Cl ...
随机推荐
- iOS模拟器的应用沙盒在MAC中的位置
每个iOS应用都有自己专属的应用沙盒.分别为 应用程序包 Documents/ Library/Caches/ Library/Preferences/ tmp/ 当运行模拟时,在MAC下找到对应路径 ...
- 初等变换求 |A| % Mod & A- % Mod & A* % Mod(模板)
// |A| * A- = A* (伴随矩阵) = 逆矩阵 * 矩阵的值 #include<cstdio> #include<cstring> #include<cstd ...
- 验证控件jQuery Validation Engine调用外部函数验证
在使用jQuery Validation Engine的时候,我们除了使用自带的API之外,还可以自己自定义正则验证.自定义正则验证上一篇已经讲过了,如果想使用自定义函数进行验证怎么办?其实这个控件有 ...
- 明天找python工作,看看这几道Python面试题吧,Python面试题No14
第1题: 如何解决验证码的问题,用什么模块,听过哪些人工打码平台? PIL.pytesser.tesseract模块 平台的话有:(打码平台特殊,不保证时效性) 云打码 挣码 斐斐打码 若快打码 超级 ...
- docker常用到的一些命令
docker ps 1. docker ps -a(显示所有的容器,包括未运行的) 2.docker ps -q (只显示ip) 3. docker ps -f(根据条件过滤显示的内容) docker ...
- Kipmi0 占用CPU 100%
查看当前正在运行的进程发现kipmi0进程占用率达到100% kipmi -% of the CPUs, %/% comes when the machine is idle? A second is ...
- n个点的基环树数量
某裴姓蒟蒻上午提了一个小问题(rt)..然后他升华了..升华之前感受到了神犇的力量... 方法一: g[n][k]表示n个点,k条边的无向图(不一定连通) f[n][k]表示表示n个点,k条边的无向连 ...
- 2017 ACM/ICPC Asia Regional Shenyang Online transaction transaction transaction
Problem Description Kelukin is a businessman. Every day, he travels around cities to do some busines ...
- myeclipse部署maven时,src/main/resources里面配置文件加载不到webapp下classes路径下的问题
解决myeclipse部署maven时,src/main/resources里面配置文件加载不到webapp下classes路径下的问题. 有时候是src/main/resources下面的,有时候是 ...
- 阿里巴巴Java开发手册_不建议在循环体中使用+进行字符串拼接
18. [推荐]循环体内,字符串的连接方式,使用StringBuilder的append方法进行扩展. 说明:下例中,反编译出的字节码文件显示每次循环都会new出一个StringBuilder对象,然 ...