Code Monkey home page Code Monkey logo

simple-geo-tool's Introduction

Simple Geographic Tool

Table of Contents

Description

Yet another (supposed to be simple) tool to add geo objects on map. Try it on GitHub Pages.

img

Main features

  • Adding object(s) on the map:
    • via inputting parameters (latitude, longitude and accuracy) in form fields for single object
    • via inputting JSON array of coordinates for single or multiple objects
    • via entering URL parameter
    • by shift-clicking on the map
    • with or without marker's pin or dot
    • with custom color, line weight and line dashes
    • by applying function to recently added objects (group objects)
  • Supported object's types:
    • point
    • circle
    • line and polyline
    • polygon
    • rectangle (only in JSON)
  • List of added objects with opportunity to:
    • view full info
    • copy object to clipboard
    • locate (fly to) certain object
    • delete certain object
    • copy all objects to clipboard
    • show all objects
    • delete all objects
  • Map controls:
    • selecting tile layers (OpenStreetMap, Wikimedia etc.)
    • geolocating current position of the device
    • show address (geocoding) in popup of object's markers (disabled by default in settings)
    • ruler for measure distance
  • Other:
    • setting of object creation and other options
    • store user settings in localStorage, also last clicked coordinates on the map as the center point of the map on next page load.

JSON format

Directly specified objects

Parameters

Parameter Type Description
type (required) String Enum:
  • "point"
  • "circle"
  • "polyline"
  • "polygon"
  • "rectangle"

Type of the object.
coords (required) Array of objects Object of the form:
{"lat": Number <double>, "lon": Number <double>}.
Where lat is latitude, from -90.0 to 90.0, and lon is longitude, from -180.0 to 180.0.

One object for type point or circle, and one or more for other.
radius Number <double> Radius of the circle, in meters. Only applicable and required to type "circle", otherwise will be ignored.
azimuth Number <double> Direction in degrees east of True North (clockwise), from 0° to 360°. If set, the dot will be replaced with an arrow. Only applicable to type "point" and "circle", otherwise will be ignored.
color String Stroke and fill CSS-color of the object. HEX, RGB(A), name etc.
weight Number <integer> Stroke width in pixels. Not applicable to "point".
dashedLine Boolean Create dashes and gaps in the stroke. Not applicable to "point".
showMarkerPin Boolean Allows to enable/disable the marker pin for object.
showMarkerDot boolean Allows to enable/disable the marker dot for object.

Usage example

Point

Example with all required parameters ("type", "coords") and almost all optional (name of "color", "azimuth", "showMarkerPin", "showMarkerDot"):

[
   {
      "type": "point",
      "coords": [
         {
            "lat": 55.039372,
            "lon": 37.552016
         }
      ],
      "color": "black",
      "azimuth": 45,
      "showMarkerPin": false,
      "showMarkerDot": true
   }
]

Circle

Example with all required parameters (type, coords, radius) and some optional (RGBA color, showMarkerPin):

[
   {
      "type": "circle",
      "coords": [
         {
            "lat": 56.325227,
            "lon": 37.854250
         }
      ],
      "radius": 10000,
      "color": "rgba(51, 136, 255,0.95)",
      "showMarkerPin": false
   }
]

Polyline

Example with all required parameters (type, coords) and one optional (HEX color):

[
   {
      "type": "polyline",
      "coords": [
         {
            "lat": 55.124319,
            "lon": 36.777198
         },
         {
            "lat": 56.273381,
            "lon": 38.777437
         },
         {
            "lat": 55.630222,
            "lon": 39.332448
         }
      ],
      "color": "#6e14ef"
   }
]

Polygon

Example only with required parameters (type, coords):

[
   {
      "type": "polygon",
      "coords": [
         {
            "lon": 36.426052,
            "lat": 56.181837
         },
         {
            "lon": 39.201706,
            "lat": 56.160414
         },
         {
            "lon": 38.987349,
            "lat": 55.143146
         },
         {
            "lon": 36.327118,
            "lat": 55.290538
         },
         {
            "lon":36.426052,
            "lat":56.181837
         }
      ]
   }
]

Objects based on recently added objects

Parameters

Parameter Type Description
type (required) String Only "group".
function (required) String Enum:
  • "drawCircleBounds"
  • "drawRectangleBounds"

Function of calculation.
objectIDs (required) Array of integers List of recently added objects IDS that will be proccessed by function. Must contain minimum one valid ID.
color String Stroke and fill CSS-color of the object. HEX, RGB(A), name etc.
weight Number <integer> Stroke width in pixels. Not applicable to "point".
dashedLine Boolean Create dashes and gaps in the stroke. Not applicable to "point".
showMarkerPin Boolean Allows to enable/disable the marker pin for object.
showMarkerDot boolean Allows to enable/disable the marker dot for object.

Usage example

This will add a "circle" object around the objects with the given IDs:

[
   {
      "type": "group",
      "function": "drawCircleBounds",
      "objectIDs": [2, 3, 7],
      "color": "black",
      "weight": 1,
      "showMarkerPin": false,
      "showMarkerDot": true
   }
]

JSON usage

Text field

Enter JSON into the text field on array tab. JSON must contain one array with one or more objects in curly brackets comma separated:

[{object_1}, {object_2}, ..., {object_n}]

URL parameters

Use URL parameter tab=array together with addArray=[{obj_1}, {obj_2}, ..., {obj_n}]:

https://bazhanius.github.io/simple-geo-tool/?tab=array&addArray=[{obj_1}, {obj_2}, ..., {obj_n}]

Dependencies

simple-geo-tool's People

Contributors

bazhanius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.