From 5e9a2219ca208c4f386cb7696a17abf050fc76b4 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Tue, 18 Feb 2014 10:02:48 -0800 Subject: [PATCH] update to work with latest polymer: - fix sizing - use local css - remove @host --- components/x-map.html | 31 ++++++++++++++++++------------- map.html | 5 ++--- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/components/x-map.html b/components/x-map.html index a09933f..37850d5 100644 --- a/components/x-map.html +++ b/components/x-map.html @@ -1,19 +1,15 @@ + + + + @@ -24,6 +20,9 @@ map: null, zoom: 12, credit: "", + observe: { + 'width height': 'updateSize' + }, ready: function() { console.log(this.height) if(!this.height) @@ -32,8 +31,6 @@ console.error("lat and lng attributes are required for x-map"); return; } - this.draw(this.$.map); - this.dispatchEvent(new Event('ready')); }, draw: function(element) { var tile = L.tileLayer( @@ -43,6 +40,14 @@ ); this.map = L.map(element).setView([this.lat, this.lng], this.zoom); tile.addTo(this.map); + }, + updateSize: function() { + this.style.width = this.$.map.style.width = this.width + 'px'; + this.style.height = this.$.map.style.height = this.height + 'px'; + if (!this.map) { + this.draw(this.$.map); + this.dispatchEvent(new Event('ready')); + } } }); diff --git a/map.html b/map.html index ed55518..5b9719e 100644 --- a/map.html +++ b/map.html @@ -3,11 +3,10 @@ A map Web Component - - + - +

A map Web Component

Minimal map