webgeolocation

Bindings to the Webgeolocation Web API

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version 1.0.0
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:25

Authors

  • Mark Leyva

Installation

nimble install webgeolocation
choosenim install webgeolocation
git clone https://github.com/maleyva1/webgeoloaction

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
webgeolocation - - - - - - -

Dependencies

Package Version Optional
nim >= 1.6.0 No

Source

Repository https://github.com/maleyva1/webgeoloaction
Homepage https://github.com/maleyva1/webgeoloaction
Registry Source nimble_official

README

Geolocation API

Nim bindings for the Geolocation Web API.

Basic usage

The following example only works on the JS target.

import std/strformat

import webgeolocation

proc success(position: GeolocationPosition): void =
    let 
        lat = position.coords.latitude
        lon = position.coords.longitude
    echo fmt"https://www.openstreetmap.org/#map=18/{lat}/{lon}".cstring
    echo fmt"Latitude: {lat}, Longitude: {lon}".cstring

proc error(error: GeolocationPositionError): void  =
    echo "Unable to retrieve your position: ".cstring & error.message

if isGeolocationAvailable():
  geolocation.getCurrentPosition(success, error)
else:
  echo "Geolcation API is unavailable!"

Demo

The demo presented on the MDN page for the Geolocation API is included in the tests/ directory.

You will need Karax to build it and Python 3 to execute the demo task.

Instructions

Run nimble demo. This will build a small Karax application which you can access at http://localhost:8080.

Docs

Build documentation with nim docs