Coder Social home page Coder Social logo

itse4elhaam / leaflet-centermarker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from heyman/leaflet-centermarker

0.0 0.0 0.0 6 KB

Leaflet Marker that is kept fixed to the center of the map

License: MIT License

JavaScript 57.96% CSS 12.40% HTML 29.65%

leaflet-centermarker's Introduction

Leaflet CenterMarker

CenterMarker is a small Leaflet plugin for adding a marker that will be fixed to the center viewport of the map, when the map is panned/dragged.

Features

Works like the default Leaflet Marker class, but it's position will be fixed relative to the viewport when the map is dragged. When the map has been dragged the CenterMarker will fire a "newposition" event.

See it in action

Leaflet CenterMarker can be seen in action on What is my address?

You can also see the bundled examples.

Example Code

Create a center marker and add it to a map:

var map = L.map('map', {keyboard: true}).setView([59.324617, 18.071457], 4);

// the marker gets it's position from map.getCenter()
var marker = L.centerMarker(map);
marker.addTo(map);
marker.on("newposition", function(ev) {
    console.log("Marker got new position:", marker.getLatLng());
});

Known limitations

Currently, the marker is only kept center when the map is panned by drag event, and not if it's panned by arrow keys on the keyboard or zooming.

Author

CenterMarker is developed by Jonatan Heyman.

License

MIT License

leaflet-centermarker's People

Contributors

heyman 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.