Giter Club home page Giter Club logo

leaflet.photomarker's Introduction

Leaflet.PhotoMarker

L.PhotoMarker is a Leaflet image marker. It takes src and size options, and displays the image as the marker icon.

Example pulling from the Flickr API

Requires Leaflet 0.5.0 or newer

Adding a photo marker

var photo_marker = new L.PhotoMarker([43.077085534225475, -89.40519332885742], {
  src: 'http://farm8.staticflickr.com/7012/6477800239_ee93da89b9_t.jpg',
  size: [ 100, 67 ]
}).addTo(map);

Scaling the photo at different zoom levels

The photo marker has a scale() method and fires a resize event when the map is zoomed, allowing you to manually change the scale at different zoom levels.

TODO: Think about an automatic algorithm for handling the size per zoom level.

var photo_marker = new L.PhotoMarker([43.077085534225475, -89.40519332885742], {
  src: 'http://farm8.staticflickr.com/7012/6477800239_ee93da89b9_t.jpg',
  size: [ 100, 67 ],
  resize: function(e) {
    var zoom = e.zoom,
        photo_marker = e.target;
    if ( zoom <= 13 ) {
      photo_marker.scale(0.25);
    }
    else if (zoom <= 15 ) {
      // Half of the size option
      photo_marker.scale(0.5);
    }
    else {
      // Scale 1 is 100% as defined in the size option
      photo_marker.scale(1);
    }
  }
}).addTo(map);

leaflet.photomarker's People

Contributors

bshelton229 avatar

Watchers

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