如果您使用的是java,我有代码可以生成kml以显示Google地球中的3D跟踪。 (加上,每个点从空气到地面的垂直线)。 (假设:既然你有2D代码,你可能已经有了从kml21.xsd转换来的java pojo代码。) (ps我可以给你附上一张图片,如果你知道任何免费的网站可以上传图片。) Hope此帮助:
package com.googleearth.util;
import java.util.List;
import javax.xml.bind.JAXBElement;
import com.a.googleearth.entities.GoogleEarthView;
import com.a.googleearth.model.AltitudeModeEnum;
import com.a.googleearth.model.DocumentType;
import com.a.googleearth.model.FolderType;
import com.a.googleearth.model.KmlType;
import com.a.googleearth.model.LineStringType;
import com.a.googleearth.model.LineStyleType;
import com.a.googleearth.model.ObjectFactory;
import com.a.googleearth.model.PlacemarkType;
import com.a.googleearth.model.StyleType;
public class KmlService {
public static final byte[] blue = new byte[]{(byte)0x64,(byte)0xF0,(byte)0x00,(byte)0xFF};
private static ObjectFactory factory = new ObjectFactory();
static final String DEFAULT_REGISTRATION_FOR_EMPTY = "EMPTY";
public static JAXBElement<KmlType> createKml(List<GoogleEarthView> listGoogleEarthDBView) {
KmlType kml = factory.createKmlType();
DocumentType document = factory.createDocumentType();
kml.setFeature(factory.createDocument(document));
{
LineStyleType redLineStyle = factory.createLineStyleType();
// http://www.zonums.com/gmaps/kml_color/
redLineStyle.setColor(new byte[]{(byte)0xFF,(byte)0xF0,(byte)0x00,(byte)0x14});
redLineStyle.setWidth(5f);
StyleType style = factory.createStyleType();
style.setId("blueLine");
style.setLineStyle(redLineStyle);
document.getStyleSelector().add(factory.createStyle(style));
}
FolderType folder = factory.createFolderType();
folder.setName(listGoogleEarthDBView.get(0).getFolderName());
document.getFeature().add(factory.createFolder(folder));
PlacemarkType currentPlacemark = null;
for (GoogleEarthView view : listGoogleEarthDBView) {
if (currentPlacemark == null || currentPlacemark.getName().equalsIgnoreCase("F0001") == false) {
if (currentPlacemark != null) {
JAXBElement<LineStringType> lineString = (JAXBElement<LineStringType>) currentPlacemark.getGeometry();
lineString.getValue().getCoordinates().add(view.getLongitude() + "," + view.getLatitude() + "," + view.getPressureAltitude()+"\n");
}
currentPlacemark = createF0001Placemark();
folder.getFeature().add(factory.createPlacemark(currentPlacemark));
}
JAXBElement<LineStringType> lineString = (JAXBElement<LineStringType>) currentPlacemark.getGeometry();
lineString.getValue().getCoordinates().add(view.getLongitude() + "," + view.getLatitude() + "," + view.getPressureAltitude()+"\n");
}
JAXBElement<KmlType> kmlElement = factory.createKml(kml);
return kmlElement;
}
private static PlacemarkType createF0001Placemark() {
PlacemarkType placeMark = factory.createPlacemarkType();
placeMark.setName("F0001");
placeMark.setStyleUrl("#blueLine");
LineStringType flyhtStreamLineString = factory.createLineStringType();
flyhtStreamLineString.setAltitudeMode(AltitudeModeEnum.ABSOLUTE);
flyhtStreamLineString.setExtrude(Boolean.TRUE);
placeMark.setGeometry(factory.createLineString(flyhtStreamLineString));
return placeMark;
}
}
太好了。我想这就是我需要的。当我回到这里时,我会尝试发布我的python解决方案。谢谢丹尼斯! – ryanjdillon