Skip to content

Commit

Permalink
updated to polymer 2
Browse files Browse the repository at this point in the history
  • Loading branch information
marko911 committed Apr 27, 2018
1 parent 3e38a25 commit 734fbe3
Show file tree
Hide file tree
Showing 13 changed files with 2,412 additions and 1,686 deletions.
40 changes: 40 additions & 0 deletions .bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "leaflet-map",
"version": "1.2.0",
"authors": [
"Hendrik Brummermann <[email protected]>",
"Prateek Saxena <[email protected]>"
],
"description": "Leaflet map as web-component based on polymer",
"main": "leaflet-map.html",
"homepage": "https://leaflet-extras.github.io/leaflet-map/",
"keywords": [
"polymer",
"web-components",
"leaflet",
"leafletjs",
"map"
],
"license": "BSD 2-Clause",
"ignore": [
"**/.*",
"demo.html",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"polymer": "^1.0.0",
"leaflet": "^0.7.3"
},
"_release": "1.2.0",
"_resolution": {
"type": "version",
"tag": "v1.2.0",
"commit": "d90a2f6d83c150c71a2461b9eb662e3a5aa96622"
},
"_source": "https://github.com/leaflet-extras/leaflet-map.git",
"_target": "^1.2.0",
"_originalSource": "leaflet-map"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ especially the api documentation, have been copied into leaflet-map files.
* [Polymer](https://github.com/polymer/polymer/blob/master/LICENSE.txt)


Copyright (c) 2014-2016
Copyright (c) 2014-2015
Hendrik Brummermann, Prateek Saxena

All rights reserved.
Expand Down
159 changes: 82 additions & 77 deletions leaflet-control.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,100 +18,105 @@
@demo https://leaflet-extras.github.io/leaflet-map/demo.html
-->

<dom-module id="leaflet-scale-control">
<style>
:host {display: none;}
</style>
<template>
</template>
<script>
"use strict";
<dom-module id="leaflet-scale-control"><style>
:host {
display: none;
}
</style>
<template>
</template>
<script>
'use strict';

Polymer({
is: 'leaflet-scale-control',
class LeafletScaleControl extends Polymer.Element {
static get is() { return 'leaflet-scale-control'; }

properties: {
static get properties() {

/**
return {
/**
* The `position` attribute sets the position of the control (one of the map corners). See control positions.
*
*
* @attribute position
* @type string
*/
position: {
type: String,
value: "bottomleft"
},

/**
* The `max-width` attribute sets the maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).
*
* @attribute max-width
* @type number
*/
maxWidth: {
type: Number,
value: 100
},

/**
* The `metric` attribute sets whether to show the metric scale line (m/km).
*
* @attribute metric
* @type boolean
*/
metric: {
type: Boolean,
value: false
},

/**
* The `imperial` attribute sets whether to show the imperial scale line (mi/ft).
*
* @attribute imperial
* @type boolean
*/
imperial: {
type: Boolean,
value: false
},

/**
* The `update-when-idle` attribute sets whether the control is updated on moveend, otherwise it's always up-to-date (updated on move).
*
* @attribute update-when-idle
* @type boolean
*/
updateWhenIdle: {
type: Boolean,
value: false
},

container: {
type: Object,
observer: '_containerChanged'
}
},
position: {
type: String,
value: 'bottomleft'
},

_containerChanged: function() {
/**
* The `max-width` attribute sets the maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).
*
* @attribute max-width
* @type number
*/
maxWidth: {
type: Number,
value: 100
},

/**
* The `metric` attribute sets whether to show the metric scale line (m/km).
*
* @attribute metric
* @type boolean
*/
metric: {
type: Boolean,
value: false
},

/**
* The `imperial` attribute sets whether to show the imperial scale line (mi/ft).
*
* @attribute imperial
* @type boolean
*/
imperial: {
type: Boolean,
value: false
},

/**
* The `update-when-idle` attribute sets whether the control is updated on moveend, otherwise it's always up-to-date (updated on move).
*
* @attribute update-when-idle
* @type boolean
*/
updateWhenIdle: {
type: Boolean,
value: false
},

container: {
type: Object,
observer: '_containerChanged'
}
};
}

_containerChanged() {
if (this.container) {
var control = L.control.scale({
position: this.position,
maxWidth: this.maxWidth,
metric: this.metric || !this.imperial,
imperial: this.imperial || !this.metric,
updateWhenIdle: this.updateWhenIdle,
position: this.position,
maxWidth: this.maxWidth,
metric: this.metric || !this.imperial,
imperial: this.imperial || !this.metric,
updateWhenIdle: this.updateWhenIdle
});
this.control = control;
this.control.addTo(this.container);
}
},
}

detached: function() {
disconnectedCallback() {
if (this.container && this.control) {
this.container.removeControl(this.control);
}
}
});
</script>
}

window.customElements.define(LeafletScaleControl.is, LeafletScaleControl);
</script>
</dom-module>
Loading

0 comments on commit 734fbe3

Please sign in to comment.