Skip to content

Instantly share code, notes, and snippets.

@onezeroonezero
Created August 21, 2018 08:38
Show Gist options
  • Save onezeroonezero/be19595b9c4606b75fdfa679dba7373b to your computer and use it in GitHub Desktop.
Save onezeroonezero/be19595b9c4606b75fdfa679dba7373b to your computer and use it in GitHub Desktop.

Revisions

  1. onezeroonezero created this gist Aug 21, 2018.
    1 change: 1 addition & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <div id="mapid"></div>
    7 changes: 7 additions & 0 deletions osm-map-pane.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    OSM map pane
    ------------


    A [Pen](https://codepen.io/onezeroonezero/pen/JajzKg) by [onezeroonezero](https://codepen.io/onezeroonezero) on [CodePen](https://codepen.io).

    [License](https://codepen.io/onezeroonezero/pen/JajzKg/license).
    29 changes: 29 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    var map = L.map('mapid').setView([51.505, -0.09], 13);

    L.tileLayer('//maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png', {
    attribution: 'Wikimedia maps beta | Map data &copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
    }).addTo(map);

    // Создаем новый pane, который не вложен в mapPane => независимый от transform
    var pane = map.createPane('fixed', document.getElementById('mapid'));

    var marker = L.marker([51.5, -0.09]).addTo(map);
    var marker2 = L.marker([51.51, -0.09]).addTo(map);

    var popup = L.popup({
    pane: 'fixed', // Указываем нужный pane
    className: 'popup-fixed',
    autoPan: false,
    }).setContent('First popup');

    var popup2 = L.popup({
    pane: 'fixed', // Указываем нужный pane
    className: 'popup-fixed',
    autoPan: false,
    }).setContent('Second popup');

    marker.bindPopup(popup);
    marker2.bindPopup(popup2);

    // Остальное добиваем стилями

    1 change: 1 addition & 0 deletions scripts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
    27 changes: 27 additions & 0 deletions style.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    html,
    body {
    height: 100%;
    }

    #mapid {
    height: 100%;
    }

    .popup-fixed {
    position: fixed;
    top: auto;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    margin: 0;
    border-radius: 0;

    .leaflet-popup-tip-container {
    display: none;
    }

    .leaflet-popup-content-wrapper {
    border-radius: 0;
    }
    }
    1 change: 1 addition & 0 deletions styles
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <link href="https://unpkg.com/[email protected]/dist/leaflet.css" rel="stylesheet" />