locked
kml RRS feed

  • Question

  • User736276958 posted

    hi

    i have started learning kml

    so plz tell me how to use kml in c#,  ie step by step simple program

    and what is sharpkml?

    is kml and sharpkml r same?

    Saturday, November 8, 2014 12:32 PM

Answers

  • User281315223 posted

    if we want to use kml in asp.net then we have to use sharpkml or any other alternative is there?

    I'm sure there are other ways of handling it, but it's likely that SharpKml is your best bet. It seems to be the one that I saw the most when looking for things related to KML within ASP.NET, although I am sure that you could just search around a bit more for "KML in ASP.NET or KMP in C#" to see if you could find any alternatives.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 8, 2014 2:10 PM

All replies

  • User281315223 posted

    The easiest way that you'll be able to use KLM (Keyhole Markup Language) within an ASP.NET application would be to use a library like SharpKML which you have already mentioned. SharpKML is a library that will allow you to write / generate KLM files within ASP.NET applications in C#.

    To get started using it, you can use the following steps :

    1. Right-click your Project within the Visual Studio Solution Explorer.
    2. Choose the "Manage NuGet Packages..." option.
    3. Ensure you have the "Online" tab selected on the right and search for "SharpKML" in the search box.
    4. Select and install all of the options that appear (SharpKlm, SharpKlm.Core, and SharpKML - KMZ) and choose "Install" :

    This will add the appropriate references to your application to use SharpKlm. Now to use them, simply open one of your files and add the following includes at the top :

    // These are KML-related libraries
    using SharpKml.Base;
    using SharpKml.Dom;
    using SharpKml.Engine;

    Then you should be able to follow the available documentation on the SharpKml site or the Getting Started area for more information on how to actually use the library to perform certain tasks. For example, generating a KML file might look something like :

    using System;
    using System.IO;
    // These are KML-related libraries
    using SharpKml.Base;
    using SharpKml.Dom;
    using SharpKml.Engine;
    
    namespace KMLExample
    {
        public partial class KMLExample : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                // This will be the location of the Placemark.
                Point point = new Point();
                point.Coordinate = new Vector(-13.163959, -72.545992);
    
                // This is the Element we are going to save to the Kml file.
                Placemark placemark = new Placemark();
                placemark.Geometry = point;
                placemark.Name = "Machu Picchu";
    
                // This allows us to save an Element easily.
                KmlFile kml = KmlFile.Create(placemark, false);
                using (FileStream stream = File.OpenWrite("Example.kml"))
                {
                    kml.Save(stream);
                }
            }
        }
    }

    Saturday, November 8, 2014 12:49 PM
  • User281315223 posted

    Additionally to answer your questions :

    so plz tell me how to use kml in c#,  ie step by step simple program

    The above response should demonstrate how to start using the library. Refer to the links on the SharpKml site for documentation on how to use the library and to read / write .kml files using it.

    and what is sharpkml?

    As mentioned earlier, SharpKml is a library that is written for ASP.NET / C# to allow you to read and write .kml files. This library isn't directly related to KML in any way, but it simply provides ways to easily manipulate .kml files without writing everything yourself.

    is kml and sharpkml r same?

    No. KML is the actual language / format that is being used within the .kml files, where as SharpKml is simply a library that allows you to read / write these types of files. 

    Saturday, November 8, 2014 12:53 PM
  • User736276958 posted

    thanks for ur reply rion william

    i had one more doubt

    if we want to use kml in asp.net then we have to use sharpkml or any other alternative is there?

     

    Saturday, November 8, 2014 1:04 PM
  • User281315223 posted

    if we want to use kml in asp.net then we have to use sharpkml or any other alternative is there?

    I'm sure there are other ways of handling it, but it's likely that SharpKml is your best bet. It seems to be the one that I saw the most when looking for things related to KML within ASP.NET, although I am sure that you could just search around a bit more for "KML in ASP.NET or KMP in C#" to see if you could find any alternatives.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 8, 2014 2:10 PM