Skip to content

Commit 7bbec39

Browse files
committed
Upgrade leaflet, switch to windspeed
1 parent 3d78f98 commit 7bbec39

File tree

7 files changed

+7790
-232
lines changed

7 files changed

+7790
-232
lines changed

index.html

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -122,37 +122,37 @@
122122
maxZoom: 20
123123
});
124124

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
154128
//})
155129

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+
156156

157157
var map = new L.Map('map', {
158158
layers: [osm, weather]
@@ -172,14 +172,14 @@
172172

173173
// draw.
174174
var repr = generators[source.provider](source);
175-
var Icon = L.Icon.extend({
175+
var icon = new L.Icon({
176176
iconUrl: repr.style.url,
177177
iconSize: new L.Point(repr.style.width, repr.style.height)
178178
});
179179
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);
183183
bounds.push(point);
184184
}
185185
map.fitBounds(new L.LatLngBounds(bounds));
File renamed without changes.

leaflet/images/popup-close.png

-1.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)