Google地球网络链接

分享于 

4分钟阅读

Web开发

  繁體

Screenshot - earth

介绍

本文旨在展示谷歌地球的网络链接的创建。

代码源

创建新的ASP.NET Web应用程序,并在 Page_Load 上复制并粘贴这里代码,或者下载源代码。

网格创建:创建网格的构造函数

Imports System.XmlPartialPublicClass _Default
 Inherits System.Web.UI.Page
 ProtectedSub Page_Load(ByVal sender AsObject,
 ByVal e As System.EventArgs) HandlesMe.Load
 Me.Response.Clear()
 Me.Response.ContentType = "application/vnd.google-earth.kml+xml"'Para ver o documento XML'For view XML document'My.Response.ContentType ="plain/text"Me.Response.ContentEncoding = System.Text.Encoding.UTF8
 Dim stream AsNew System.IO.MemoryStream
 Dim XMLwrite AsNew XmlTextWriter(stream, System.Text.Encoding.UTF8)
 XMLwrite.WriteStartDocument()
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteStartElement("kml")
 XMLwrite.WriteAttributeString("xmlns",
 "http://earth.google.com/kml/2.0")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 '<Document> XMLwrite.WriteStartElement("Document")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteElementString("name", "Signal Control")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 '<Placemark> XMLwrite.WriteStartElement("Placemark")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteElementString("description", "MY DESCRIPTION/MINHA DESCRIÇÃO")
 XMLwrite.WriteElementString("name", "MY NAME/MEU NOME")
 XMLwrite.WriteStartElement("LookAt")
 XMLwrite.WriteElementString("longitude", "MY LONGITUDE/MINHA LONGITUDE")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteElementString("latitude", "MY LATITUDE/MINHA LATITUDE")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteEndElement()
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteElementString("visibility", "1")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 '<Style> XMLwrite.WriteStartElement("Style")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 '<IconStyle> XMLwrite.WriteStartElement("IconStyle")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 '<Icon> XMLwrite.WriteStartElement("Icon")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 'Meu ícone, mudar este diretório'My Icon, change this directory XMLwrite.WriteElementString("href", "C:Code_Project1.ico")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteElementString("w", "-1")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteElementString("h", "-1")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteEndElement()
 '</Icon> XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteEndElement()
 '</IconStyle> XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteEndElement()
 '</Style>'<Point> XMLwrite.WriteStartElement("Point")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 'Minhas coordenadas, mudar aqui'My Coordinates, change aqui XMLwrite.WriteElementString("coordinates", 
 "-25.4942072754", "-49.5426559491",
 "50")
 XMLwrite.WriteWhitespace(Environment.NewLine)
 XMLwrite.WriteEndElement()
 XMLwrite.WriteEndElement()
 '</Point>'Fim do XML'Finish XML XMLwrite.WriteEndDocument()
 XMLwrite.Flush()
 Dim reader As IO.StreamReader
 stream.Position = 0 reader = New IO.StreamReader(stream)
 Dim bytes() AsByte = System.Text.Encoding.UTF8.GetBytes(reader.ReadToEnd())
 Me.Response.BinaryWrite(bytes)
 Me.Response.End()
 EndSubEndClass

Points of Interest

转到Google地球上的位置并单击添加网络链接。

Screenshot - image002.jpg

Screenshot - image003.jpg

编译项目后,将出现这里 icon:

Screenshot - image004.jpg

我的链接已经创建:

Screenshot - image005.jpg


相关文章