nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 2a38d35c75625ce657cfcb1fa07e9c6f21ff007a
parent d24cebe5e695d6cf14358001c3d1e3aea78b102c
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Sat, 25 Mar 2017 01:15:22 +0300

imported rotated-marker plugin to vendor dir

Diffstat:
Mpackage.json | 1-
Msrc/lib/leaflet.control.azimuth/index.js | 3+--
Asrc/vendored/github.com/bbecquet/Leaflet.RotatedMarker/LICENSE | 22++++++++++++++++++++++
Asrc/vendored/github.com/bbecquet/Leaflet.RotatedMarker/README.md | 45+++++++++++++++++++++++++++++++++++++++++++++
Asrc/vendored/github.com/bbecquet/Leaflet.RotatedMarker/example.html | 41+++++++++++++++++++++++++++++++++++++++++
Asrc/vendored/github.com/bbecquet/Leaflet.RotatedMarker/leaflet.rotatedMarker.js | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/vendored/github.com/bbecquet/Leaflet.RotatedMarker/package.json | 16++++++++++++++++
7 files changed, 187 insertions(+), 3 deletions(-)

diff --git a/package.json b/package.json @@ -59,7 +59,6 @@ "image-promise": "^4.0.1", "knockout": "^3.4.0", "leaflet": "1.0.3", - "leaflet-rotatedmarker": "^0.1.2", "load-script": "^1.0.0", "raven-js": "^3.12.0", "rbush": "^2.0.1", diff --git a/src/lib/leaflet.control.azimuth/index.js b/src/lib/leaflet.control.azimuth/index.js @@ -5,8 +5,7 @@ import layout from './control.html'; import 'lib/controls-styles/controls-styles.css'; import './style.css'; import {getDeclination} from 'lib/magnetic-declination'; -//FIXME: replace with vendored version -import 'leaflet-rotatedmarker'; +import 'vendored/github.com/bbecquet/Leaflet.RotatedMarker/leaflet.rotatedMarker'; import iconPointer from './pointer.svg'; import iconPointerStart from './pointer-start.svg'; import iconPointerEnd from './pointer-end.svg'; diff --git a/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/LICENSE b/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Benjamin Becquet + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/README.md b/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/README.md @@ -0,0 +1,45 @@ +Leaflet Rotated Marker +=== + +Enables rotation of marker icons in Leaflet. + +Compatible with versions 0.7.* and 1.* of Leaflet. Doesn't work on IE < 9. + +```bash +npm install leaflet-rotatedmarker +``` + +Usage +--- + +```js +L.marker([48.8631169, 2.3708919], { + rotationAngle: 45 +}).addTo(map); +``` + +API +--- + +It simply extends the `L.Marker` class with two new options: + +Option | Type | Default | Description +-------|------|---------|------------ +**`rotationAngle`** | `Number` | 0 | Rotation angle, in degrees, clockwise. +**`rotationOrigin`** | `String` | `'bottom center'` | The rotation center, as a [`transform-origin`](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin) CSS rule. + +and two new methods: + +Method | Returns | Description +-------|---------|------------ +**`setRotationAngle(newAngle)`** | `this` | Sets the rotation angle value. +**`setRotationOrigin(newOrigin)`** | `this` | Sets the rotation origin value. + +The default `rotationOrigin` value will rotate around the bottom center point, corresponding to the "tip" of the marker for most commonly used icons. If your marker icon has no tip, or you want to rotate around its center, use `center center`. + +Note +--- + +On purpose, it doesn't rotate marker icon shadows. Mainly because there is no way to make it look good with the perspective of classic, pin type shadows (anyway, these shadows are so 2005, right?). + +So just disable icon shadows, or use simple ones which will work for all marker angles. diff --git a/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/example.html b/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/example.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> + + <title>Leaflet rotated marker example</title> + + <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v1.0.0/leaflet.css" /> + <style> + * { margin: 0; padding: 0; } + html, body { height: 100%; } + #map { width:100%; height:100%; } + </style> + + <script src="http://cdn.leafletjs.com/leaflet/v1.0.0/leaflet-src.js"></script> + <script src="leaflet.rotatedMarker.js"></script> + <script> + window.onload = function() { + var map = L.map('map', { + center: [48.8631169, 2.3708919], + zoom: 8, + layers: [ + L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { + attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' + }) + ] + }); + + var m = L.marker(map.getCenter(), { + rotationAngle: 45, + draggable: true + }).addTo(map); + }; + </script> + </head> + + <body> + <div id="map"></div> + </body> +</html> diff --git a/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/leaflet.rotatedMarker.js b/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/leaflet.rotatedMarker.js @@ -0,0 +1,62 @@ +(function() { + // save these original methods before they are overwritten + var proto_initIcon = L.Marker.prototype._initIcon; + var proto_setPos = L.Marker.prototype._setPos; + var proto_onDrag = L.Handler.MarkerDrag.prototype._onDrag; + + var oldIE = (L.DomUtil.TRANSFORM === 'msTransform'); + + L.Marker.addInitHook(function () { + var iconOptions = this.options.icon && this.options.icon.options; + var iconAnchor = iconOptions && this.options.icon.options.iconAnchor; + if (iconAnchor) { + iconAnchor = (iconAnchor[0] + 'px ' + iconAnchor[1] + 'px'); + } + this.options.rotationOrigin = this.options.rotationOrigin || iconAnchor || 'center bottom' ; + this.options.rotationAngle = this.options.rotationAngle || 0; + }); + + L.Marker.include({ + _initIcon: function() { + proto_initIcon.call(this); + }, + + _setPos: function (pos) { + proto_setPos.call(this, pos); + this._applyRotation(); + }, + + _applyRotation: function () { + if(this.options.rotationAngle) { + this._icon.style[L.DomUtil.TRANSFORM+'Origin'] = this.options.rotationOrigin; + + if(oldIE) { + // for IE 9, use the 2D rotation + this._icon.style[L.DomUtil.TRANSFORM] = 'rotate(' + this.options.rotationAngle + 'deg)'; + } else { + // for modern browsers, prefer the 3D accelerated version + this._icon.style[L.DomUtil.TRANSFORM] += ' rotateZ(' + this.options.rotationAngle + 'deg)'; + } + } + }, + + setRotationAngle: function(angle) { + this.options.rotationAngle = angle; + this.update(); + return this; + }, + + setRotationOrigin: function(origin) { + this.options.rotationOrigin = origin; + this.update(); + return this; + } + }); + + L.Handler.MarkerDrag.include({ + _onDrag: function (e) { + proto_onDrag.call(this, e); + this._marker._applyRotation(); + } + }) +})(); diff --git a/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/package.json b/src/vendored/github.com/bbecquet/Leaflet.RotatedMarker/package.json @@ -0,0 +1,16 @@ +{ + "name": "leaflet-rotatedmarker", + "version": "0.1.2", + "description": "Enables rotation of marker icons in Leaflet.", + "main": "leaflet.rotatedMarker.js", + "repository": { + "type": "git", + "url": "git@github.com:bbecquet/Leaflet.RotatedMarker.git" + }, + "author": { + "name": "Benjamin Becquet", + "email": "benjamin.becquet@gmail.com", + "url": "http://bbecquet.net" + }, + "license": "MIT" +}