GithubHelp home page GithubHelp logo

geojson2.net's Introduction

Geojson.net2

Summary

Geojson.net2 is an alternative library for transforming a C# object into a Geojson Object

Installation

To start using this libraty all you have to do is install the GeoJSON.Net2 NuGet package:

PM> Install-Package GeoJson.net2

How to use it

Example: Just create a geojson object (Point, Polygon or LineString) and pass a coordinates list as an argument.

public Geojson MyPolygon ()

       {

           List<LatLng> Coordinates = new List<LatLng>();
           Coordinates.Add(new LatLng(41.02135510866602, -471.06079101562506));
           Coordinates.Add(new LatLng(45.01141864227728, -471.06079101562506));
           Coordinates.Add(new LatLng(45.01141864227728, -464.08447265625));
           Coordinates.Add(new LatLng(41.02135510866602, -464.08447265625));
           Coordinates.Add(new LatLng(41.02135510866602, -471.06079101562506));

           return new Polygon(Coordinates);
       }

you can send the geojson object as an ajax result and use it in your js code, or if you prefer it you can use Newtonsoft.Json to serialize it and get this result:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -471.06079101562506,
              41.021355108666022
            ],
            [
              -471.06079101562506,
              45.011418642277278
            ],
            [
              -464.08447265625,
              45.011418642277278
            ],
            [
              -464.08447265625,
              41.021355108666022
            ],
            [
              -471.06079101562506,
              41.021355108666022
            ]
          ]
        ]
      },
      "properties": {
        "FeatureType": "Polygon",
        "Color": "#3289c7"
      }
    }
  ]
}

Thank you!

geojson2.net's People

Contributors

cesipro avatar darthcharles avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

geojson2.net's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.