/// <summary> /// KmlDocument 의 Visibility 변경 /// </summary> /// <param name="document"></param> /// <param name="isVisible"></param> public void SetKmlDocumentVisible(IKmlDocument document, bool isVisible) { if (document == null) { System.Console.WriteLine("SetKmlDocumentVisible - KmlDocument is null"); FileLogManager.GetInstance().WriteLog("[GEController] SetKmlDocumentVisible( KmlDocument is null )"); return; } try { document.setVisibility(Convert.ToInt32(isVisible)); KmlObjectListCoClass kmlObjectListCoClass = document.getFeatures().getChildNodes(); for (int i = 0; i < kmlObjectListCoClass.getLength(); i++) { IKmlObject kmlObject = kmlObjectListCoClass.item(i); string strType = kmlObject.getType(); if (strType == "KmlPlacemark") { IKmlPlacemark placemark = kmlObject as IKmlPlacemark; placemark.setVisibility(Convert.ToInt32(isVisible)); } } } catch (Exception ex) { System.Console.WriteLine("SetKmlDocumentVisible Exception : " + ex.ToString()); FileLogManager.GetInstance().WriteLog("[GEController] SetKmlDocumentVisible( " + ex.ToString() + " )"); } }
public bool RemoveKml(IKmlObject obj) { try { if (this.ge == null) { FileLogManager.GetInstance().WriteLog("[GEController] RemoveKml( GEPlugin is null )"); throw new Exception("External Exception : GEPlugin is null."); } if (ge.getFeatures() == null) { return(false); } ge.getFeatures().removeChild(obj); } catch (Exception ex) { System.Console.WriteLine("RemoveKml Exception : " + ex.ToString()); FileLogManager.GetInstance().WriteLog("[GEController] RemoveKml( " + ex.ToString() + " )"); return(false); } return(true); }
/// <summary> /// Kml 을 parse 하여 GEPlugin 에 로드 /// </summary> /// <param name="kml"></param> /// <returns></returns> public IKmlObject AppendKml(string kml) { try { if (this.ge == null) { FileLogManager.GetInstance().WriteLog("[GEController] AppendKml( GEPlugin is null )"); throw new Exception("External Exception : GEPlugin is null."); } IKmlObject obj = ge.parseKml(kml.Trim()); return(ge.getFeatures().appendChild(obj)); } catch (Exception ex) { System.Console.WriteLine("AppendKml Exception : " + ex.ToString()); FileLogManager.GetInstance().WriteLog("[GEController] AppendKml( " + ex.ToString() + " )"); return(null); } }
/// <summary> /// Icon을 생성하여 GEPlugin 에 Append /// </summary> /// <param name="iconInfo"></param> public IKmlObject CreateSystemIcon(IconInfo iconInfo) { try { if (this.ge == null) { FileLogManager.GetInstance().WriteLog("[GEController] CreateSystemIcon2( GEPlugin is null. )"); throw new Exception("External Exception : GEPlugin is null."); } StringBuilder builder = new StringBuilder(); builder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); builder.Append("<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\""); builder.Append(" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">"); builder.Append("<Placemark id=\""); builder.Append("icon" + iconInfo.IconName); builder.Append("\">"); builder.Append("<name></name>"); if (iconInfo.LstExtendedData.Count > 0) { builder.Append("<ExtendedData>"); foreach (KmlExtendedData extendData in iconInfo.LstExtendedData) { builder.Append("<Data name=\""); builder.Append(extendData.DataName); builder.Append("\">"); builder.Append("<value>"); builder.Append(extendData.Data); builder.Append("</value>"); builder.Append("</Data>"); } builder.Append("</ExtendedData>"); } builder.Append("</Placemark>"); builder.Append("</kml>"); IKmlObject obj = ge.parseKml(builder.ToString()); //아이콘 생성---------------------------------------시작 IKmlPlacemark placemark = obj as IKmlPlacemark; placemark.setDescription(iconInfo.IconName); if (!string.IsNullOrEmpty(iconInfo.IconURL)) { //아이콘 스타일 변경----------------------------시작 IKmlIcon icon = ge.createIcon(""); icon.setHref(iconInfo.IconURL); IKmlStyle style = ge.createStyle(""); style.getIconStyle().setIcon(icon); placemark.setStyleSelector(style); //아이콘 스타일 변경------------------------------끝 } else { //아이콘 스타일 변경----------------------------시작 IKmlIcon icon = ge.createIcon(""); icon.setHref("http://maps.google.com/mapfiles/kml/paddle/red-circle.png"); IKmlStyle style = ge.createStyle(""); style.getIconStyle().setIcon(icon); placemark.setStyleSelector(style); //아이콘 스타일 변경------------------------------끝 } IKmlPoint point = ge.createPoint(""); point.setLatitude(iconInfo.Latitude); point.setLongitude(iconInfo.Longitude); placemark.setGeometry(point); return(ge.getFeatures().appendChild(placemark)); //아이콘 생성-----------------------------------------끝 } catch (Exception ex) { System.Console.WriteLine("CreateSystemIcon2 Exception : " + ex.ToString()); FileLogManager.GetInstance().WriteLog("[GEController] CreateSystemIcon2( GEPlugin is null. )"); return(null); } }