2015-06-22 94 views
0

我想使用c#在kml文件中添加我的公司徽標。在kml文件中添加徽標

我已經嘗試了很多東西,但沒有任何工作。

請提前幫助我。

+2

顯示你已經嘗試了什麼。 –

+0

http://stackoverflow.com/questions/15376320/writing-a-kml-using-c-sharp-screenoverlay?rq=1 –

回答

0

要將您的徽標添加到KML,您可以將ScreenOverlay添加到KML。

屏幕覆蓋圖定義的圖像總是出現在屏幕上的一個固定位置,當您更改位置或放大/縮小時,該位置不會改變。另一方面,圖像覆蓋圖固定在地圖上隨視圖更改而移動的位置。

爲了使徽標出現在左下角的地圖添加到您的KML:

<ScreenOverlay> 
    <name>Logo</name> 
    <description>Screen overlay Example</description> 
    <Icon> 
     <href>http://www.google.com/intl/en_ALL/images/logo.gif</href> 
    </Icon> 
    <!-- put image at the left-corner of the image --> 
    <overlayXY x="0" y="0" xunits="fraction" yunits="fraction" /> 
    <screenXY x="5" y="5" xunits="pixels" yunits="pixels" />  
    </ScreenOverlay> 

<overlayXY>元素定義了一個點的圖像和<screenXY> 定義地圖上的錨點疊加圖像被錨定到。覆蓋圖中的點可以在像素座標系或分數座標系中定義。

首先讓KML達到您希望它出現在Google地球中的方式,然後對您的C#代碼進行更改以生成它。

對於KML一個徽標的現實世界的例子見美國地質勘探局地震KML
http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month_age_link.kml

+0

string strdocA = Server.MapPath(「〜/ Document/KML/doc.kml」) ; string strdocB = Server.MapPath(「〜/ Document/KML/MaxConLOGOnew.kml」); string strdocC = Server.MapPath(「〜/ Document/KML/vvkml」); –

+0

XmlTextWriter kml = new XmlTextWriter(path,null); kml.Formatting = Formatting.Indented; kml.WriteStartElement(「kml」,strdocA); kml.WriteStartElement(「ScreenOverlay」); kml.WriteElementString(「name」,「elephant」); kml.WriteStartElement(「Icon」); kml.WriteElementString(「href」,「images/elephant.jpg」); kml.WriteEndElement(); –

+0

kml.WriteStartElement(「overlayXY」); kml.WriteAttributeString(「x」,「0」); kml.WriteAttributeString(「y」,「1」); kml.WriteAttributeString(「xunits」,「fraction」); kml.WriteAttributeString(「yunits」,「fraction」); kml.WriteEndElement(); –