|
6 | 6 |
|
7 | 7 | <!-- this is a modified version of leaflet which uses Polymer.dom instead of |
8 | 8 | regular DOM API calls so as to work with Shadow/Shady DOM custom elements --> |
9 | | -<script src="../polymer-leaflet/leaflet.js"></script> |
| 9 | +<script src="../polymer-leaflet/leaflet-src.js"></script> |
10 | 10 | <script src="../proj4Leaflet/lib/proj4-compressed.js"></script> |
11 | 11 | <script src="../proj4Leaflet/src/proj4leaflet.js"></script> |
12 | 12 | <script src="../mapml-leaflet-plugin/mapml.min.js"></script> |
|
149 | 149 | this.lon = this._map.getCenter().lng; |
150 | 150 | this.zoom = this._map.getZoom(); |
151 | 151 | }, |
| 152 | + ready: function () { |
| 153 | + // when used in a custom element, the leaflet script element is hidden inside |
| 154 | + // the import's shadow dom. |
| 155 | + L.Icon.Default.imagePath = (function () { |
| 156 | + var imp = document.querySelector('link[rel="import"][href*="web-map.html"]'), |
| 157 | + doc = imp ? imp.import : document, |
| 158 | + scripts = doc.getElementsByTagName('script'), |
| 159 | + leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/; |
| 160 | + |
| 161 | + var i, len, src, path; |
| 162 | + |
| 163 | + for (i = 0, len = scripts.length; i < len; i++) { |
| 164 | + src = scripts[i].src; |
| 165 | + |
| 166 | + if (src.match(leafletRe)) { |
| 167 | + path = src.split(leafletRe)[0]; |
| 168 | + return (path ? path + '/' : '') + 'images'; |
| 169 | + } |
| 170 | + } |
| 171 | + }()); |
| 172 | + |
| 173 | + }, |
152 | 174 | attached: function() { |
153 | 175 | this.async( function () { |
154 | 176 | console.log(this.localName + '#' + this.id + ' was attached'); |
|
180 | 202 | // _container.innerHTML does not work properly if the engine is throwing |
181 | 203 | // exceptions because there are no area element children of the image map |
182 | 204 | // for firefox only, a workaround is to actually remove the image... |
183 | | - if (L.Browser.gecko) { |
184 | | - this.poster.removeAttribute('usemap'); |
185 | | - } |
186 | 205 | if (this.poster) { |
187 | | - Polymer.dom(this.$.map).appendChild(this.poster); |
| 206 | + if (L.Browser.gecko) { |
| 207 | + this.poster.removeAttribute('usemap'); |
| 208 | + } |
| 209 | + Polymer.dom(this.$.map).appendChild(this.poster); |
188 | 210 | } |
189 | 211 | } |
190 | 212 | } |
|
0 commit comments