Skip to content

Commit 1cbee87

Browse files
committed
[leaflet] Brand new test file
1 parent bc19614 commit 1cbee87

File tree

1 file changed

+301
-0
lines changed

1 file changed

+301
-0
lines changed

leaflet/leaflet-tests.ts

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
/// <reference path="leaflet.d.ts" />
2+
3+
// initialize the map on the "map" div with a given center and zoom
4+
5+
var div = document.getElementById('map');
6+
7+
var map : L.Map = L.map(div, {
8+
center: L.latLng([51.505, -0.09]),
9+
zoom: 13,
10+
minZoom: 3,
11+
maxZoom: 8,
12+
maxBounds: L.latLngBounds([L.latLng(-60, -60), L.latLng(60, 60)]),
13+
dragging: true,
14+
touchZoom: true,
15+
scrollWheelZoom: true,
16+
boxZoom: true,
17+
tap: true,
18+
19+
tapTolerance: 30,
20+
trackResize: true,
21+
worldCopyJump: false,
22+
closePopupOnClick: true,
23+
bounceAtZoomLimits: true,
24+
25+
keyboard: true,
26+
keyboardPanOffset: 80,
27+
keyboardZoomOffset: 1,
28+
29+
inertia: true,
30+
inertiaDeceleration: 3000,
31+
inertiaMaxSpeed: 1500,
32+
inertiaThreshold: 32,
33+
34+
zoomControl: true,
35+
attributionControl: true,
36+
37+
fadeAnimation: true,
38+
zoomAnimation: true,
39+
zoomAnimationThreshold: 4,
40+
markerZoomAnimation: true
41+
42+
});
43+
44+
map.dragging.enable();
45+
map.touchZoom.enable();
46+
map.scrollWheelZoom.enable();
47+
map.doubleClickZoom.enable();
48+
map.boxZoom.enable();
49+
map.tap.enable();
50+
51+
map.setView(new L.LatLng(42, 51));
52+
map.setView(L.latLng(42, 51));
53+
54+
map.setView(L.latLng(42, 51), 12);
55+
map.setView(L.latLng(42, 51), 12, {
56+
reset: true,
57+
pan: {
58+
animate: true,
59+
duration: 0.25,
60+
easeLinearity: 0.25,
61+
noMoveStart: false
62+
},
63+
zoom: {
64+
animate: true
65+
}
66+
});
67+
68+
map.setZoom(50);
69+
map.setZoom(50, {});
70+
71+
map.zoomIn();
72+
map.zoomOut();
73+
74+
map.zoomIn(2);
75+
map.zoomOut(2);
76+
77+
map.zoomIn(2, { animate: true });
78+
map.zoomOut(2, { animate: true });
79+
80+
map.setZoomAround(L.latLng(42, 51), 8, { animate: false });
81+
82+
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
83+
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)), {
84+
paddingTopLeft: L.point(20, 20),
85+
paddingBottomRight: L.point(20, 20),
86+
padding: L.point(0, 0),
87+
maxZoom: null
88+
});
89+
90+
map.fitWorld();
91+
92+
map.fitWorld({
93+
animate: false
94+
});
95+
96+
map.panTo(L.latLng(42, 42));
97+
map.panTo(L.latLng(42, 42), {
98+
animate: true
99+
});
100+
101+
map.invalidateSize(true);
102+
map.invalidateSize({ reset: true });
103+
104+
map.setMaxBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
105+
106+
map.locate();
107+
map.locate({
108+
watch: false,
109+
setView: false,
110+
maxZoom: 18,
111+
timeout: 10000,
112+
maximumAge: 0,
113+
enableHighAccuracy: false
114+
});
115+
116+
map.stopLocate();
117+
118+
map.remove();
119+
120+
var center : L.LatLng = map.getCenter();
121+
var zoom : number = map.getZoom();
122+
var minZoom: number = map.getMinZoom();
123+
var maxZoom: number = map.getMaxZoom();
124+
var bounds: L.LatLngBounds = map.getBounds();
125+
var boundsZoom: number = map.getBoundsZoom(bounds, true);
126+
var size: L.Point = map.getSize();
127+
var pixelBounds: L.Bounds = map.getPixelBounds();
128+
var pixelOrigin: L.Point = map.getPixelOrigin();
129+
130+
var layer = L.tileLayer("http://{s}.example.net/{x}/{y}/{z}.png");
131+
132+
map.addLayer(layer);
133+
map.addLayer(layer, false);
134+
135+
map.removeLayer(layer);
136+
map.hasLayer(layer);
137+
138+
map.openPopup("canard", L.latLng(42, 51));
139+
140+
var popup = L.popup({
141+
autoPan: true
142+
});
143+
144+
map.openPopup(popup);
145+
map.closePopup(popup);
146+
map.closePopup();
147+
148+
map.addControl(L.control.attribution({position: 'bottomright'}));
149+
map.removeControl(L.control.attribution({ position: 'bottomright' }));
150+
151+
map.latLngToLayerPoint(map.layerPointToLatLng(L.point(0, 0)));
152+
map.latLngToContainerPoint(map.containerPointToLatLng(L.point(0, 0)));
153+
map.containerPointToLayerPoint(L.point(0, 0));
154+
map.layerPointToContainerPoint(L.point(0, 0));
155+
156+
map.project(map.unproject(L.point(10, 20)));
157+
map.project(map.unproject(L.point(10, 20), 12), 12);
158+
159+
var mouseEvent: L.LeafletMouseEvent;
160+
map.mouseEventToContainerPoint(mouseEvent);
161+
map.mouseEventToLayerPoint(mouseEvent);
162+
map.mouseEventToLatLng(mouseEvent);
163+
164+
map.getContainer().classList.add('roger');
165+
map.getPanes().mapPane.classList.add('roger');
166+
map.getPanes().markerPane.classList.add('roger');
167+
map.getPanes().objectsPane.classList.add('roger');
168+
map.getPanes().overlayPane.classList.add('roger');
169+
map.getPanes().popupPane.classList.add('roger');
170+
map.getPanes().shadowPane.classList.add('roger');
171+
map.getPanes().tilePane.classList.add('roger');
172+
173+
map.whenReady((m: L.Map) => {
174+
m.zoomOut();
175+
});
176+
177+
map.on('click', () => {
178+
map.zoomOut();
179+
});
180+
181+
map.off('dblclick', L.Util.falseFn);
182+
183+
map.once('contextmenu', (e: L.LeafletMouseEvent) => {
184+
map.openPopup('contextmenu', e.latlng);
185+
});
186+
187+
var marker = L.marker(L.latLng(42, 51), {
188+
icon: L.icon({
189+
iconURl: 'roger.png',
190+
iconRetinaUrl: 'roger-retina.png',
191+
iconSize: L.point(40, 40),
192+
iconAnchor: L.point(20, 0),
193+
shadowUrl: 'roger-shadow.png',
194+
shadowRetinaUrl: 'roger-shadow-retina.png',
195+
shadowSize: L.point(44, 44),
196+
shadowAnchor: L.point(22, 0),
197+
popupAnchor: L.point(0, 0),
198+
className: 'roger-icon'
199+
}),
200+
clickable: true,
201+
draggable: false,
202+
keyboard: true,
203+
title: 'this is an icon',
204+
alt: '',
205+
zIndexOffset: 0,
206+
opacity: 1.0,
207+
riseOnHover: false,
208+
riseOffset: 250
209+
});
210+
211+
marker.addTo(map);
212+
213+
marker.on('click', (e: L.LeafletMouseEvent) => {
214+
map.setView(e.latlng);
215+
});
216+
217+
marker.once('mouseover', () => {
218+
marker.openPopup();
219+
})
220+
221+
marker.setLatLng(marker.getLatLng());
222+
223+
marker.setIcon(L.icon({}));
224+
225+
marker.setZIndexOffset(30);
226+
marker.setOpacity(0.8);
227+
228+
marker.bindPopup(popup);
229+
marker.unbindPopup();
230+
marker.bindPopup('hello', {
231+
closeOnClick: true
232+
});
233+
234+
marker.openPopup();
235+
marker.closePopup();
236+
marker.togglePopup();
237+
marker.togglePopup();
238+
marker.setPopupContent('hello 3')
239+
marker.getPopup().setContent('hello 2');
240+
marker.update();
241+
242+
marker.toGeoJSON();
243+
244+
marker.dragging.enable();
245+
246+
popup = L.popup({
247+
maxWidth: 300,
248+
minWidth: 50,
249+
maxHeight: null,
250+
autoPan: true,
251+
keepInView: false,
252+
closeButton: true,
253+
offset: L.point(0, 6),
254+
autoPanPaddingTopLeft: null,
255+
autoPanPaddingBottomRight: L.point(20, 20),
256+
autoPanPadding: L.point(5, 5),
257+
zoomAnimation: true,
258+
closeOnClick: null,
259+
className: 'roger'
260+
});
261+
262+
popup.setLatLng(L.latLng(12, 54)).setContent('this is nice popup').openOn(map);
263+
264+
popup.update();
265+
266+
var tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {
267+
foo: 'bar',
268+
minZoom: 0,
269+
maxZoom: 18,
270+
maxNativeZoom: 17,
271+
tileSize: 256,
272+
subdomains: ['a','b','c'],
273+
errorTileUrl: '',
274+
attribution: '',
275+
tms: false,
276+
continuousWorld: false,
277+
noWrap: false,
278+
zoomOffset: 0,
279+
zoomReverse: false,
280+
opacity: 1.0,
281+
zIndex: null,
282+
unloadInvisibleTiles: false,
283+
updateWhenIdle: false,
284+
detectRetina: true,
285+
reuseTiles: true,
286+
bounds: null
287+
});
288+
289+
tileLayer.on('loading', L.Util.falseFn)
290+
.off('loading', L.Util.falseFn)
291+
.once('tileload', L.Util.falseFn);
292+
293+
tileLayer.addTo(map);
294+
295+
tileLayer.bringToBack()
296+
.bringToFront()
297+
.setOpacity(0.7)
298+
.setZIndex(9)
299+
.redraw()
300+
.setUrl('http://perdu.com')
301+
.getContainer();

0 commit comments

Comments
 (0)