在气球内部显示带有照片的多个地标的最佳做法是什么? [英] Whats the best pratice to show multiple placemarks with photos inside of the ballons?
问题描述
我有一个项目,如下所示:从手机上拍摄了几张照片,这些照片保存在网络系统中,该系统又将照片显示在其中的google Earth上.我读过许多文章,但所有文章都使用fetchKml,我读过的一篇好文章是使用php,但使用fetchKml.我不知道是否可以使用parseKml代替.无论如何,我不确定如何使用kml来执行此操作,因此它看起来像这样:
I have a project as follows: Several photos are taken from a mobile, the photos are saved in a web system, which in turn displays the photos on google earth that is inside it. I've read many articles but all of them were using fetchKml, one good article that i've read was using php, but using fetchKml. I dont know if its possible using parseKml instead. Anyway, I'm not sure how to do this with the kml, so it looks tike this:
我的班级KMLGenerator()
My Class KMLGenerator()
public static String getKMLFromObra (List<Obra> obraFotos) {
StringBuffer sb = new StringBuffer();
sb.append("<?xml version='1.0' encoding='UTF-8'?>");
sb.append("<kml xmlns='http://www.opengis.net/kml/2.2' " +
"xmlns:gx='http://www.google.com/kml/ext/2.2' " +
"xmlns:kml='http://www.opengis.net/kml/2.2' " +
"xmlns:atom='http://www.w3.org/2005/Atom'> ");
if (obraFotos != null && obraFotos.size() > 0) {
for (Obra o : obraFotos) {
for (Local local : o.getLocais()) {
sb.append("<Document>");
sb.append("<name>" + local.getName() + "</name>");
sb.append("<Style id='defaultStyles'>");
sb.append("<IconStyle>");
sb.append("<scale>1.1</scale>");
sb.append("<Icon>");
sb.append("<href>" + "http://localhost:8080/ConstruMobilFoto/lib/img/fotoIcon.png" + "</href>");
sb.append("</Icon>");
sb.append("</IconStyle>");
sb.append("</Style>");
sb.append("<Placemark>");
sb.append("<name>" + "Foto" + "</name>");
sb.append("<styleUrl>" + "#defaultStyles"+ "</styleUrl>");
sb.append("<altitudeMode>" + "relativeToGround" + "</altitudeMode>");
sb.append("<Point>");
sb.append("<altitudeMode>relativeToGround</altitudeMode>");
sb.append("<coordinates>" + local.getLongitude() + "," + local.getLatitude() + "," + 50</coordinates>");
sb.append("</Point>");
sb.append("<Link>");
sb.append("<href>" + local.getFotos() + "</href>");
sb.append("</Link>");
sb.append("</Placemark>");
sb.append("</Document>");
sb.append("</kml>");
return sb.toString();
}
}
}
return null;
}
我的jsp中有一个dwr函数,该函数调用此方法,获取其String结果并进行如下解析:
I have a dwr function in my jsp that invokes this method, got its String results and make the parse like this:
PainelEarth()类
Class PainelEarth()
@SuppressWarnings("static-access")
public String geraFotosObra (int idObra) throws Exception {
try {
List<Obra> obraFotos = obraBusiness.getObraLatLong(new Obra(idObra));
return new KMLGenerator().getKMLFromObra(obraFotos);
} catch (Exception e) {
log.error(e.getLocalizedMessage(), e);
return null;
}
}
在我的jsp页面中
function initCB(instance) {
// other codes
showPics(ge);
}
function showPics(ge) {
PainelEarthAjax.geraFotosObra({
callback : function(kmlString) {
var kmlObject = ge.parseKml(kmlString);
ge.getFeatures().appendChild(kmlObject);
}
});
return null;
}
任何帮助都将受到欢迎!
Any help will be welcome!!
推荐答案
在代码中,如果查看方法geraFotosObra
的签名,则可以看到它仅包含一个int
参数idObra
.
In your code if you look at the signature of the method geraFotosObra
you can see it takes a single int
parameter idObra
.
public String geraFotosObra (int idObra) throws Exception { ...
但是,当您在jsp中调用该方法时,您正在传递包含回调函数的对象文字.
Yet when you call the method in your jsp you are passing an an object literal containing a callback function.
PainelEarthAjax.geraFotosObra({
callback : function(kmlString) { ...
因为它是我不知道如何生成kml,除非geraFotosObra
是重载方法?而且即使按原样生成它,我也看不到如何调用您代替id的回调函数-例如,为什么kmlString
会成为对geraFotosObra
的调用的结果? /p>
As it is I don't see how the kml is generated, unless perhaps geraFotosObra
is an overloaded method? Also even if it was generated, as is, I don't see how the callback function that you pass in place of an id is ever called - why for example would kmlString
be the result of the call to geraFotosObra
?
// How is this called, what sets kmlString!?
callback : function(kmlString) {
var kmlObject = ge.parseKml(kmlString);
ge.getFeatures().appendChild(kmlObject);
}
您发布的所有代码总有些令人困惑,因此,如果我错过了某些事情,对不起...我认为您可能已经从fetchKml示例中复制并粘贴了一些代码,并且与该方法一起使用的异步回调已引起混淆你咯.
All in all the code you posted is a wee bit confusing, so sorry if I have missed something...I think you have possibly copy and pasted some code from a fetchKml example and the asynchronous callbacks used with that method have confused you slightly.
无论如何,根据发布的内容,您应该将int
id
传递给geraFotosObra
方法,获取字符串结果,然后在插件中对其进行解析.
Anyhow, based on what you have posted, you should be passing an int
id
to the geraFotosObra
method, getting the string result and then parsing it in the plug-in.
类似下面的事情是有道理的.用以下内容替换showPics
函数.
Something like the following makes sense. Replace the showPics
function with the following.
function showPics(ge) {
var kmlString = PainelEarthAjax.geraFotosObra(1); // or something?
var kmlObject = ge.parseKml(kmlString);
ge.getFeatures().appendChild(kmlObject);
}
这篇关于在气球内部显示带有照片的多个地标的最佳做法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!