|
122 | 122 | maxZoom: 20 |
123 | 123 | }); |
124 | 124 |
|
125 | | -var weather = new L.TileLayer("http://openweathermap.org/t/tile.cgi/1.0.0/GLBETA_PR/{z}/{x}/{y}.png", { |
126 | | - attribution: "<a href='http://openweathermap.org'>Weather data by OpenWeatherMap.org</a>", |
127 | | - opacity: 0.2 |
128 | | -}) |
129 | | - |
130 | | -//var WeatherLayer = L.TileLayer.WMS.extend({ |
131 | | -// getTileUrl: function(tilePoint, zoom) { |
132 | | -// var map = this._map, |
133 | | -// crs = map.options.crs, |
134 | | -// tileSize = this.options.tileSize, |
135 | | -// |
136 | | -// nwPoint = tilePoint.multiplyBy(tileSize), |
137 | | -// sePoint = nwPoint.add(new L.Point(tileSize, tileSize)), |
138 | | -// |
139 | | -// nw = crs.project(map.unproject(nwPoint, zoom)), |
140 | | -// se = crs.project(map.unproject(sePoint, zoom)), |
141 | | -// |
142 | | -// |
143 | | -// bbox = [nw.x, se.y, se.x, nw.y].join(','); |
144 | | -// return "http://openweathermap.org/t/t?url=SERVICE=WMS%26REQUEST=GetMap%26FORMAT=image%2Fpng%26TRANSPARENT=true%26VERSION=1.1.1%26SRS=EPSG%3A900913%26HEIGHT=256%26WIDTH=256%26LAYERS=GLBETA_UV%26BBOX=" + bbox; |
145 | | -// } |
146 | | -//}); |
147 | | -// |
148 | | -// |
149 | | -//var weather = new WeatherLayer("http://openweathermap.org/t/t?url=", { |
150 | | -// opacity: 0.3, |
151 | | -// maxZoom: 5, |
152 | | -// minZoom: 1, |
153 | | -// noWrap: true |
| 125 | +//var weather = new L.TileLayer("http://openweathermap.org/t/tile.cgi/1.0.0/GLBETA_PR/{z}/{x}/{y}.png", { |
| 126 | +// attribution: "<a href='http://openweathermap.org'>Weather data by OpenWeatherMap.org</a>", |
| 127 | +// opacity: 0.2 |
154 | 128 | //}) |
155 | 129 |
|
| 130 | +var WeatherLayer = L.TileLayer.WMS.extend({ |
| 131 | + getTileUrl: function(tilePoint, zoom) { |
| 132 | + var map = this._map, |
| 133 | + crs = map.options.crs, |
| 134 | + tileSize = this.options.tileSize, |
| 135 | + |
| 136 | + nwPoint = tilePoint.multiplyBy(tileSize), |
| 137 | + sePoint = nwPoint.add(new L.Point(tileSize, tileSize)), |
| 138 | + |
| 139 | + nw = crs.project(map.unproject(nwPoint, zoom)), |
| 140 | + se = crs.project(map.unproject(sePoint, zoom)), |
| 141 | + |
| 142 | + |
| 143 | + bbox = [nw.x, se.y, se.x, nw.y].join(','); |
| 144 | + return "http://openweathermap.org/t/t?url=SERVICE=WMS%26REQUEST=GetMap%26FORMAT=image%2Fpng%26TRANSPARENT=true%26VERSION=1.1.1%26SRS=EPSG%3A900913%26HEIGHT=256%26WIDTH=256%26LAYERS=GLBETA_UV%26BBOX=" + bbox; |
| 145 | + } |
| 146 | +}); |
| 147 | + |
| 148 | + |
| 149 | +var weather = new WeatherLayer("http://openweathermap.org/t/t?url=", { |
| 150 | + opacity: 0.3, |
| 151 | + minZoom: 1, |
| 152 | + noWrap: true, |
| 153 | + attribution: "<a href='http://openweathermap.org'>Windspeed data by OpenWeatherMap.org</a>" |
| 154 | +}) |
| 155 | + |
156 | 156 |
|
157 | 157 | var map = new L.Map('map', { |
158 | 158 | layers: [osm, weather] |
|
172 | 172 |
|
173 | 173 | // draw. |
174 | 174 | var repr = generators[source.provider](source); |
175 | | - var Icon = L.Icon.extend({ |
| 175 | + var icon = new L.Icon({ |
176 | 176 | iconUrl: repr.style.url, |
177 | 177 | iconSize: new L.Point(repr.style.width, repr.style.height) |
178 | 178 | }); |
179 | 179 | var point = new L.LatLng(lat, lng); |
180 | | - var marker = new L.Marker(point, {icon: new Icon()}) |
181 | | - marker.bindPopup(repr.html) |
182 | | - map.addLayer(marker); |
| 180 | + var marker = new L.Marker(point, {icon: icon}) |
| 181 | + marker.addTo(map); |
| 182 | + marker.bindPopup(repr.html); |
183 | 183 | bounds.push(point); |
184 | 184 | } |
185 | 185 | map.fitBounds(new L.LatLngBounds(bounds)); |
|
0 commit comments