请问我在1.kml文件中定义了一条线的kml格式转换,然后我想在2.kml文件中使用1.kml中定义的kml格式转换,这样能实现吗?

互联网+国家战略智库
? ? ? ? ? ?
当前位置: &
& Google Earth 6.1版本新增KML文件功能
Google Earth 6.1版本新增KML文件功能
&&日12:06&&中国电子商务研究中心
  (中国电子商务研究中心讯)谷歌的Google Earth和Google Earth Pro升级到6.1版本了,近日Google官方又透露了一些跟KML有关的跟开发者有关的新功能。  首先是线性标签的变化。Labels标签功能在Google Earth 6.1里默认是关闭的,但你可以利用里的在标准的直线中间显示标签名,比如下面的KML文件。  然后由于Google还改进了街景的,包括视野更宽广的街景游览模式,所以开发者也可以使用和里的标签来使用这一特性。(网届网)
&&&& 5月17日,中国电子商务研究中心发布《2016年度中国网络零售市场数据监测报告》(报告全文下载:),涉及领域包括农村电商(代表有:农村淘宝、京东农村、中国惠农网)、进口跨境电商(代表有:天猫国际、京东全球购、网易考拉海购)、母婴电商(代表有:宝贝格子、贝贝网、蜜芽)、生鲜电商(代表有:盒马鲜生、易果生鲜、京东生鲜)、淘品牌(代表有:三只松鼠、百草味、茵曼、韩都衣舍)、移动电商(代表有:唯品会、天猫、国美)、电商快递(代表有:申通、中通、圆通、韵达、顺丰)等。
【】【】【】【】【】
「关键字」
& &(1)凡本中心注明“来源:中国电子商务研究中心”或带有中国电子商务研究中心水印LOGO的所有文字、图片、音频、视频及其他任何形式的作品 ,其版权均属中国电子商务研究中心所有,任何媒体、网站或个人未经本中心协议授权不得转载、链接、转贴或以其他方式复制发布/发表。已与本中心协议授权的媒体、网站,在下载使用时必须注明“稿件来源:中国电子商务研究中心”,违者本中心将依法追究责任。
& &(2)转载或引用本中心内容必须是以新闻性或资料性公共免费信息为使用目的的合理、善意引用,不得对本中心内容原意进行曲解、修改,同时必须保留本中心注明的“稿件来源”,并自负版权等法律责任。
& &(3)对于不当转载或引用本中心内容而引起的民事纷争、行政处理或其他损失,本中心不承担责任。
& &(4)凡本中心注明“来源:xxx(非中国电子商务研究中心)”的文/图等稿件,均转载自其它媒体、网站与机构,其转载目的在于传递更多信息,并不代表本中心赞同其观点和对其真实性负责,请读者仅作参考,并请自行核实相关内容,如其他媒体、网站或个人从本网下载使用,必须保留本网注明的“稿件来源”,并自负版权等法律责任。& &(5)关于本中心发布的用户投诉稿件,信息均由用户通过本中心投诉通道提供,本中心不对其真实性负责,若内容真实性有误,请与本中心联系,本中心将在核实后进行处理。& &(6)对不遵守本声明或其他违法、恶意使用本中心内容者,本中心保留追究其法律责任的权利。& &(7)如因作品内容、版权和其它问题需要同本中心联系的请发送相关内容至邮箱:)& &此版权声明解释权归中国电子商务研究中心所有。
  2016年网络零售行业逐步成熟、线上线下融合持续推进、新技术推动服务升级,种种现象都在表明网络零售的...
生态型企业:
行业热点:
曝光专区:
有以下事宜,请联系:&&
有以下事宜,请联系:
有以下事宜,请联系:
以下企业,请联系:
以下企业,请联系:
以下企业,请联系:
以下人士,请联系:
行业/频道:
产品/服务:
数据/研究:
导航/平台:
中国电子商务研究中心 版权所有如何将dwg文件转成kml文件_图文-1
如何将dwg文件转成kml文件_计算机软件及应用_IT/计算机_专业资料。很多的朋友遇到这么一个问题,自己手里的CAD图纸是dwg格式的,想要导入Google earth内查看,但是...
现在就教教大家如何将dwg文件转成kml文件,希望对大家有所帮助。如何直接将 dwg 文件转成 kml 文件做项目的时候手里有 dwg 格式的文件,需要加载到 Google earth ...
暂无评价|0人阅读|0次下载|举报文档 [转]_如何把google地图导入CAD制图_电力/...7、对保存好的“水库”右键,选择“将位置另存为” 8、另存为 KML 格式 9...
将范围界线的*.dwg 文件直接 拖到 Global mapper14 软件下释放, 弹出投影对话...选择 “文件” ― “输出” ― “矢量格式” , 选择输出格式“KML/KMZ” ,...
暂无评价|0人阅读|0次下载|举报文档 googleearth导入cad制图《转》_计算机软件及...7、对保存好的“水库”右键,选择“将位置另存为” 8、另存为 KML 格式 9...
插件:acad2kml.vlx 3. 示例数据:Drawing2.dwg 二、目的 在 AutoCAD 中,用 acad2kml.vlx 插件将 CAD 图形数 据转换成 kml,导入 LocaSpace Viewer 。三、...
EXCEL GPS坐标点转换为KML流程_建筑/土木_工程科技_专业资料。原创EXCEL GPS坐标点转换为KML流程,采用Global Mapper软件。EXCEL GPS 坐标点转换为 KML 流程 1、将...
Global mapper将KML导出为TAB步骤_计算机软件及应用_...2、选择 KML 文件并打开,效果如下。其中镇区的...步骤中选择 OK,并在图 4 出现时 为 Tab 文件...
很多时候,有些盗版的PKPM生成的T文件打开后转不成DWG文件,或者由于版本不同T文件打开后转不成DWG文件,此时需要如何解决,此问题通过我一些日常经验可以解决!希望对...
的数据,但 Google Earth 的 kml,却无法直接在熟悉的 GIS 软件上 使用,这篇文章就以 ESRI 的 ARCGIS 来作个示范,教大家如何将 kml 文件转 为 shape 文件。 ...本博专注于基于微软技术的搜索相关技术
posts - 189, comments - 3707, trackbacks - 26, articles - 0
google maps 的 KML 文件可以用于静态的地图标注,在某些应用中,我们手上往往有成百上千个地址,我们需要把这些地址和描述批量标注到 google maps 上去,如果手工来做,太耗时间,在这里我写了一个程序批量来生成这个 KML 文件。 首先看一下 KML 文件的格式:&?xml version="1.0" encoding="UTF-8"?&
&kml xmlns="/earth/kml/2"&
&Document&
&name&kml_sample2.kml&/name&
&Style id="red"&
&IconStyle&
&href&/intl/en_us/mapfiles/ms/icons/red-dot.png&/href&
&/IconStyle&
&Style id="green"&
&IconStyle&
&href&/intl/en_us/mapfiles/ms/icons/green-dot.png&/href&
&/IconStyle&
&Style id="blue"&
&IconStyle&
&href&/intl/en_us/mapfiles/ms/icons/blue-dot.png&/href&
&/IconStyle&
&Placemark&
&name&Google Inc.&/name&
&description&&![CDATA[
Google Inc.&br /&
1600 Amphitheatre Parkway&br /&
Mountain View, CA 94043&br /&
Phone: +1 650-253-0000&br /&
Fax: +1 650-253-0001&br /&
&p&Home page: &a href=""&&/a&&/p&
&/description&
&styleUrl&#red&/styleUrl&
&coordinates&-122..&/coordinates&
&/Placemark&
&Placemark&
&name&Yahoo! Inc.&/name&
&description&&![CDATA[
Yahoo! Inc.&br /&
701 First Avenue&br /&
Sunnyvale, CA 94089&br /&
Tel: (408) 349-3300&br /&
Fax: (408) 349-3301&br /&
&p&Home page: &a href=""&&/a&&/p&
&/description&
&styleUrl&#green&/styleUrl&
&coordinates&-122..4163228&/coordinates&
&/Placemark&
&/Document&
这个是一个典型的用于google maps 的 KML 文件,(注意不同应用的KML 格式会有所不同,比如 google earth 的 kml 格式就复杂得多)
从这个kml 文件格式来看,其实它就是一个 xml 文件,我们只要自动生成这个文件中各个元素的信息就可以得到这个xml& 文件。这里其实最大的问题是如何自动通过地址获取经纬度坐标。值得庆幸的是 google 提供了这方面的 api 函数。google api 获取地理坐标的官方例子见:
我的实现稍微复杂一些,因为我需要在函数中为不同的位置自动分配颜色
/// &summary&
/// Generate placemark by address description
/// &/summary&
/// &param name="addrDescription"&address and description&/param&
/// &returns&if no matched, return false&/returns&
public bool Generate(AddressDescription addrDescription)
_LastErrorOrWarning = null;
Thread.Sleep(DelayInMs);
List&GeographicCoordinate& coordinates = Geocoding.Geocode(addrDescription.Address);
if (coordinates.Count == 0)
_LastErrorOrWarning = string.Format("Address:{0}, Description:{1} does not find the coordinates, please make sure the address is correctly.",
addrDescription.Address, addrDescription.Description);
return false;
if (coordinates.Count & 1)
_LastErrorOrWarning = string.Format("Address:{0}, Description:{1} has more than one coordinates.",
addrDescription.Address, addrDescription.Description);
string colorId = Colors[_ColorIndex];
_ColorIndex++;
if (_ColorIndex &= Colors.Count)
_ColorIndex = 0;
_Kml.Document.Add(new Placemark(addrDescription.Address, addrDescription.Description, colorId,
coordinates[0].Latitude, coordinates[0].Longitude));
return true;
&第32行有个bug,应该是 &=& ,我原来写成 & 了,博客中我改过来了,源码我就不改了。 如上代码,第12行就是通过GeocodingApi 获取指定地址的物理坐标,由于有时候获取不到坐标,有时候由于地址不确切,有多个坐标,所以我加了一个错误和警告的属性,用于调用者得到相关的信息。
_Kml 这个对象是一个 Kml 类的实例,这个类用于生成 KML 文件结构,并可以保存到KML文件中。这个类在后面介绍。
下面的 _Color 部分是自动的顺序分配标注点的颜色,我为了省事,在代码中写死了4种颜色,你也可以修改代码增加颜色或其他图标。
标注颜色这里其实还有一个问题,就是如果让相邻的节点显示不同颜色,这个算法比较复杂了,我没有实现,各位如果有兴趣可以思考一下这个怎么做。
好了,最大的问题解决了,剩下就是写 xml& 文件了,这个很简单,我就不深入讲了,直接把代码贴出来。using S
using System.Collections.G
using System.L
using System.T
using System.X
using System.Xml.S
using System.IO;
namespace GenerateKML
public class Placemark
public class KMLPoint
public KMLPoint()
public KMLPoint(double latitude, double longitude)
SetCoordinates(latitude, longitude);
private string _
public void SetCoordinates(double latitude, double longitude)
_coordinates = longitude.ToString() + "," + latitude.ToString();
public string coordinates
_coordinates = value;
[XmlElement("name")]
public string Name { }
[XmlElement("description")]
public string Description { }
[XmlElement("styleUrl")]
public string StyleUrl { }
public KMLPoint Point { }
public Placemark()
public Placemark(string name, string description, string styleUrl,
double latitude, double longitude)
Description =
StyleUrl = styleU
Point = new KMLPoint(latitude, longitude);
public class kml
[XmlIgnore]
string Name { }
List&Placemark& _Placemarks = new List&Placemark&();
[XmlArray()]
public List&Placemark& Document
_Placemarks = value;
public kml()
public kml(string name)
private XmlNode GetColorStyle(XmlDocument xmlDoc,
string color)
XmlNode style = xmlDoc.CreateNode(XmlNodeType.Element, "Style", "");
XmlAttribute attr = style.OwnerDocument.CreateAttribute("id");
attr.Value =
style.Attributes.Append(attr);
XmlNode iconStyle = xmlDoc.CreateNode(XmlNodeType.Element, "IconStyle", "");
XmlNode icon = xmlDoc.CreateNode(XmlNodeType.Element, "Icon", "");
XmlNode href = xmlDoc.CreateNode(XmlNodeType.Element, "href", "");
href.InnerText = string.Format("/intl/en_us/mapfiles/ms/icons/{0}-dot.png",
style.AppendChild(iconStyle);
iconStyle.AppendChild(icon);
icon.AppendChild(href);
public void SaveToFile(string xml)
using (FileStream fs = new FileStream(xml, FileMode.Create, FileAccess.ReadWrite))
using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
XmlSerializer serializer = new XmlSerializer(this.GetType());
serializer.Serialize(sw, this);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xml);
xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
XmlNode documentNode = xmlDoc.SelectSingleNode(@"/kml/Document");
XmlNode nameNode = xmlDoc.CreateNode(XmlNodeType.Element, "name", "");
nameNode.InnerText = this.N
XmlNode placeMarkNode = documentNode.FirstC
documentNode.InsertBefore(nameNode, placeMarkNode);
documentNode.InsertBefore(GetColorStyle(xmlDoc, "red"), placeMarkNode);
documentNode.InsertBefore(GetColorStyle(xmlDoc, "green"), placeMarkNode);
documentNode.InsertBefore(GetColorStyle(xmlDoc, "blue"), placeMarkNode);
documentNode.InsertBefore(GetColorStyle(xmlDoc, "yellow"), placeMarkNode);
XmlNode kmlNode = xmlDoc.SelectSingleNode(@"/kml");
XmlAttribute attr = kmlNode.OwnerDocument.CreateAttribute("xmlns");
attr.Value = "/kml/2.0";
kmlNode.Attributes.Append(attr);
xmlDoc.Save(xml);
下面看一下调用的方法,使用者如果不想仔细研究细节,那就关注这个就可以了,调用方法非常简单
static void Main(string[] args)
Generator kmlGenerator = new Generator("Test");
kmlGenerator.Generate(new AddressDescription("1600 Amphitheatre Parkway, Mountain View, CA 94043",
"Google"));
if (!string.IsNullOrEmpty(kmlGenerator.LastErrorOrWarning))
Console.WriteLine(kmlGenerator.LastErrorOrWarning);
kmlGenerator.Generate(new AddressDescription("1 Microsoft Way, Redmond, WA 98052",
"Microsoft"));
if (!string.IsNullOrEmpty(kmlGenerator.LastErrorOrWarning))
Console.WriteLine(kmlGenerator.LastErrorOrWarning);
kmlGenerator.Generate(new AddressDescription("1601 S. California Ave., Palo Alto, CA 95304",
"Facebook"));
if (!string.IsNullOrEmpty(kmlGenerator.LastErrorOrWarning))
Console.WriteLine(kmlGenerator.LastErrorOrWarning);
kmlGenerator.Generate(new AddressDescription("701 First Ave, Sunnyvale, CA 94089",
"Yahoo"));
if (!string.IsNullOrEmpty(kmlGenerator.LastErrorOrWarning))
Console.WriteLine(kmlGenerator.LastErrorOrWarning);
kmlGenerator.Save("test.kml");
第三行,实例化 KML 生成器,并指定一个名字,这个名字对于 kml 文档中的 name 字段。
第五行,在kml 文件中标注 google 总部的地址
第八行,判断是否有最新的错误,每次执行第五行的Generate 方法,会将最新错误清空,所以这里永远是得到最近一次调用 Generate 方法的错误或警告。
后面以此类推了。
最后 Save 到一个kml文件中就OK了。
最后,我们可以把这个 kml 文件导入到我们自己创建的 google map 中。这个在 google maps 里面有相应的导入功能,这里就不介绍了。
完整源码下载
注意源码中 app.config 文件中
&add key="GeocodingApi.Key" value="google api key" /&
&add key="GeocodingApi.Url" value="/maps/geo?" /&
GeocodingApi.key 这里要填写你自己的 google api key,你可以在 google& 网站上获取,地址如下:.kml文件怎么用?
.kml文件怎么用?
09-04-20 &
kml文件同kmz文件一样,是作为保存地标文件的.其引入引出方法与kmz类似,只是选择文件格式为kml就行了. kml与kmz不同的是,它是一种xml描述语言,是文本文件格式的.所以有它的优点,比如,可以直接贴在本网页上. 由于是文本文件格式,其格式我们可以掌握,因而能通过程序自动生成kml语句. 二.earth里的使用 引入方法:与kmz文件一样,直接打开就行了. 引出方法:与kmz文件类似,但在输入文件名时,要选择存为kml文件. 三.如何从网页上copy下来,生成引入的kml文件 1.在你的earth里,先随便引出任一kml地标文件 2.在资源浏览器里用鼠标右键点按此文件,选择菜单&打开方式&--&&记事本(notepad)&,注意不要双击此kml文件 3.在博客上打开已发布的kml文本网页 4.从菜单中选择“全选”,“拷贝” 5.回到2中记事本打开的kml文件里,按&ctrl-A&或用菜单“全选”全选所有文本,按&ctrl-V&或菜单&粘贴&粘贴从网页中copy来的文本 6.把包括“-------------------”以前的文本,不包括“&/kml&”以后的文本删除,然后按菜单&保存&保存文件 7.在earth中打开或直接在资源浏览器里双击此kml文件,即引入了此kml文件 8.注意kml文件引入后,可能不会放在temporary places里,而是直接放在它原来的文件夹里
请登录后再发表评论!}

我要回帖

更多关于 kml是什么格式 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信