如何在backbone.js + jquery mobile中使用google earth API?
我使用backbone.js,underscore.js和jQuery Mobile创建了应用程序.谷歌地球API,我使用在列出的示例代码https://developers.google.com/earth/documentation/#using_the_google_earth_api
我的模板渲染,所有其他页面工作正常但是当我在一个标签中加载谷歌地球API,它没有加载,在js控制台我得到消息:"ERR_INVALID_DIV".
Google.earth模块从不回调initCallback,当调用google.earth.createInstance时,它总是调用failureCallback.
我解释一下我的应用程序的一些示例代码,所以基于这可能是你得到我的代码结构,它可以帮助你解决我的问题.
我的js代码如下,
myjs1.js
var ge;
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance) {
console.log(' init call back call ');
ge = instance;
ge.getWindow().setVisibility(true);
}
function failureCB(errorCode) {
console.log(errorCode);
}
Run Code Online (Sandbox Code Playgroud)
现在我的Backbone代码如下,
myjs2.js
WebApp.MyPage= Backbone.View.extend({
initialize:function (result) {
this.template =_.template($('#myPage').html());
},
render:function (eventName) {
var self = this;
mydata = object dict of my data;
$(self.el).html(self.template({mydata:mydata}));
google.load("earth", "1");
init();
google.setOnLoadCallback(init);
}
Run Code Online (Sandbox Code Playgroud)
现在我的HTML代码如下,
<script type="text/template" id="myPage">
<div data-role="page">
<div data-role="content"> …Run Code Online (Sandbox Code Playgroud) 有没有人知道如何使用本地磁盘或网络驱动器中的映像显示自定义KML Placemark图标.
我试过这个并没有用:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Style id="icon">
<IconStyle>
<Icon>
<href>c:\etnasss.jpg</href>
</Icon>
</IconStyle>
</Style>
<Placemark>
<name>Simple placemark</name>
<description>Attached to the ground. Intelligently places itself
at the height of the underlying terrain.</description>
<styleUrl>#icon</styleUrl>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
</Point>
</Placemark>
</kml>
Run Code Online (Sandbox Code Playgroud)
谢谢
我遇到了IIS和KMZ文件的特殊问题.我已经将MIME类型添加到IIS并且它工作正常 - 但是,似乎随机删除了MIME类型.现在已经发生了几次,每次我要解决的问题都是再次添加MIME类型.
报告损坏的链接时会识别该问题,并且一旦我将MIME类型添加回来就很好.
有关导致它的原因的任何想法,或找出造成它的原因的方法?
谢谢!
是否可以在Internet Explorer的网页中检测是否使用Javascript在客户端计算机上安装了Google Earth应用程序?
此页面是Intranet上可信站点的一部分.
更新:通过创建ActiveX对象或任何IE特定的JavaScript检测它是好的.
是否可以创建一个由几个较小的KMZ文件组成的KMZ文件?我宁愿不必手动合并实际的KML实体,但如果这是唯一的选择,我会.
我生成的KML文件可能有50,000个或更多的地标,根据特定于域的分组排列在文件夹中.KML文件使用打包到KMZ文件中的自定义图像.
我正在寻找将单个KML文件分解为多个文件,根据分组进行分区,因此我没有一个包含文件夹的大文档,而是有一个根/索引KML文件,文件夹链接到较小的KML文件.
这可能吗?我认为KMZ文件在zip中只能包含1个KML文件,无论它位于何处或其名称.此外,我不确定KML文件如何链接到另一个KML文件.是将它作为<NetworkLink>本地文件的唯一方法吗?可以<NetworkLink>链接到同一KMZ中的本地文件吗?
我正在开发一个涉及使用Java创建KML的项目.目前,我在使用Micromata Labs JAK示例中的KML示例中的示例Java代码.我试图通过添加多个坐标并获得两个标记来"扩展"代码,但我无法使其工作.你能告诉我如何添加多个坐标并在其上放置标记,并在标记之间画一条线.谢谢您的帮助!
PS:我需要通过程序来做到这一点.我看到了使用DOM和XML的示例代码,但不是纯Java/JAK.请指导我.
我得到了这个(更新):
kml.createAndSetDocument().withName("MyMarkers")
.createAndAddPlacemark().withName("London, UK").withOpen(Boolean.TRUE)
.createAndSetPoint().addToCoordinates(-0.126236, 51.500152);
kml.createAndSetDocument().withName("MyMarkers")
.createAndAddPlacemark().withName("Somewhere near London,UK").withOpen(Boolean.TRUE)
.createAndSetPoint().addToCoordinates(-0.129800,52.70??0152);
Run Code Online (Sandbox Code Playgroud)
但我知道我在某个地方出错了.请指出我正确的方向.
以下是生成的KML输出:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<Document>
<name>MyMarkers</name>
<Placemark>
<name>Somewhere near London, UK</name>
<open>1</open>
<Point>
<coordinates>-0.1298,52.700152</coordinates>
</Point>
</Placemark>
</Document>
</kml>
Run Code Online (Sandbox Code Playgroud)
我似乎无法再次访问Document以添加更多地标.我该怎么做?
基本上,我正在尝试将 Google Earth div 上的 KML 文件添加/显示到我的网站。我将我的文件命名为“satellites.kml”。
<!-- html code starts...-->
<p><iframe
name="myKMLEarth"
src="/getrack/satellites.kml"
height="440"
width="100%"
frameborder="0"
scrolling="no">
</iframe></p>
<!-- html code continues ...-->
Run Code Online (Sandbox Code Playgroud)
页面加载时,它会下载我的 KML,而不是在 iframe 中打开它。我不应该使用 src 链接到 KML 文件吗?任何意见,将不胜感激!先感谢您!
我想提交由ArcGIS 10.1和GoogleEarthPRO (GE)生成的KML文件作为我在Elsevier的论文的补充数据。
\n\n然而,审阅者给我回信:“属性“xsi:schemaLocation\xe2\x80\x9d”的前缀“xsi”中有一个错误。
\n\n当我尝试通过添加 .xml 扩展名并放入 Chrome 来简单验证 KML 文件时(如下: http: //kml4earth.appspot.com/kmlBestPractice.html),我收到错误:
\n\nerror on line 3 at column 217: Namespace prefix xsi for schemaLocation\non Document is not defined\nRun Code Online (Sandbox Code Playgroud)\n\n我通过ArcGIS 10.1(shp to KML,工具:Layer To KML)生成了KML,它生成了压缩的.kmz文件。我在 GoogleEarthPRO 中打开 .kmz 文件,并再次将我的位置保存为 .kml 文件。显然,.kml 文件运行良好,我可以在 GE 中打开该文件并在 PC 之间共享。
\n\n\n\n我还在这里尝试了 KMLvalidator: http: //www.kmlvalidator.org/validate.htm,但出现错误:
\n\nFile upload request was rejected. (/data/tomcat/base-kml-validator/temp/upload_2a88fa18_1591832a38f__7fff_00001631.tmp (No such file or directory)).\nRun Code Online (Sandbox Code Playgroud)\n\n我不明白为什么我的 .kml 文件似乎在多台 PC 上的 GoogleEarthPRO 中工作正常,但它显然包含 …
我使用十六进制颜色来标记图标。对于蓝色,我使用0000ff. 在 KML 文件中,它是<color>ff0000ff</color>. 但是,当在 Google 地球中打开 KML 时,图标地标为红色。
查看https://developers.google.com/kml/documentation/kmlreference我的看法是颜色应该编码为ff+ hexadecimal number,因此黑色表示为ff000000,这有效,但ff0000ff蓝色则不然。
我尝试了各种样式和图标选项,但没有成功。我已经阅读并看到了如何合并图标和颜色的分层效果。似乎使用wht-blank.png将是一个中性画布来应用颜色,但我怀疑它可能会产生干扰。
下面是我的测试kml。
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<name>kml_test</name>
<Placemark>
<name>uniq_name</name>
<Style>
<IconStyle>
<scale>1</scale>
<color>ff0000ff</color>
<Icon>
<href>http://maps.google.com/mapfiles/kml/paddle/wht-blank.png</href>
</Icon>
</IconStyle>
</Style>
<LabelStyle>
<color>ffffffff</color>
<scale>0.6</scale>
</LabelStyle>
<LookAt>
<longitude>-118.000000</longitude>
<latitude>34.000000</latitude>
<range>1000</range>
</LookAt>
<Point>
<altitudeMode>clampToGround</altitudeMode>
<extrude>0</extrude>
<coordinates>-118.000000,34.000000,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
Run Code Online (Sandbox Code Playgroud)
我希望<color>ff0000ff</color>在 Google Earth 中打开 kml 时显示蓝色图标,而不是红色图标。
google-earth ×10
kml ×7
kmz ×4
backbone.js ×1
debugging ×1
html ×1
icons ×1
iframe ×1
iis ×1
jak ×1
java ×1
javascript ×1
mime-types ×1
partitioning ×1