1
<html xmlns="http://www.w3.org/1999/xhtml" debug="true">
3
<title>OpenLayers: Popup Mayhem</title>
4
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
5
<link rel="stylesheet" href="style.css" type="text/css" />
6
<style type="text/css">
10
border: 1px solid black;
11
background-color: blue;
15
<link rel="stylesheet" href="../theme/default/framedCloud.css" type="text/css" />
17
<script src="../lib/Firebug/firebug.js"></script>
18
<script src="../lib/OpenLayers.js"></script>
19
<script type="text/javascript">
25
var samplePopupContentsHTML = "Old man down, way down down, down by the docks of the city.<br>Blind and dirty, asked me for a dime, a dime for a cup of coffee.<br>I got no dime but I got some time to hear his story.<br>My name is August West, and I love my Pearly Baker best more than my wine.<br>More than my wine - more than my maker, though he's no friend of mine.<br><br>Everyone said, I'd come to no good, I knew I would Pearly, believe them.<br>Half of my life, I spent doin' time for some other fucker's crime,<br>The other half found me stumbling 'round drunk on Burgundy wine.<br><br>But I'll get back on my feet again someday,<br>The good Lord willin', if He says I may.<br>I know that the life i'm livin's no good,<br>I'll get a new start, live the life I should.<br>I'll get up and fly away, I'll get up and fly away, fly away.<br><br>Pearly's been true, true to me, true to my dyin' day he said,<br>I said to him, I said to him, I'm sure she's been.<br>I said to him, I'm sure she's been tru to you.<br><br>Got up and wandered, wandered downtown, nowhere to go but just hang around.<br>I've got a girl, named Bonnie Lee, I know that girl's been true to me.<br>I know she's been, I'm sure she's been true to me.<br><br>";
26
var samplePopupContentsHTML_WideShort = "Old man down, way down down, down by the docks of the city.Blind and dirty, asked me for a dime, a dime for a cup of coffee.I got no dime but I got some time to hear his story.My name is August West, and I love my Pearly Baker best more than my wine.More than my wine - more than my maker, though he's no friend of mine.Everyone said, I'd come to no good, I knew I would Pearly, believe them.<br>Half of my life, I spent doin' time for some other fucker's crime,The other half found me stumbling 'round drunk on Burgundy wine.But I'll get back on my feet again someday,The good Lord willin', if He says I may.I know that the life i'm livin's no good,I'll get a new start, live the life I should.I'll get up and fly away, I'll get up and fly away, fly away.Pearly's been true, true to me, true to my dyin' day he said,I said to him, I said to him, I'm sure she's been.I said to him, I'm sure she's been tru to you.Got up and wandered, wandered downtown, nowhere to go but just hang around.I've got a girl, named Bonnie Lee, I know that girl's been true to me.I know she's been, I'm sure she's been true to me.";
28
// different popup types
31
AutoSizeAnchored = OpenLayers.Class(OpenLayers.Popup.Anchored, {
35
AutoSizeAnchoredMinSize = OpenLayers.Class(OpenLayers.Popup.Anchored, {
37
'minSize': new OpenLayers.Size(400,400)
40
AutoSizeAnchoredMaxSize = OpenLayers.Class(OpenLayers.Popup.Anchored, {
42
'maxSize': new OpenLayers.Size(100,100)
47
AutoSizeAnchoredBubble = OpenLayers.Class(OpenLayers.Popup.AnchoredBubble, {
51
AutoSizeAnchoredBubbleMinSize = OpenLayers.Class(OpenLayers.Popup.AnchoredBubble, {
53
'minSize': new OpenLayers.Size(400,400)
56
AutoSizeAnchoredBubbleMaxSize = OpenLayers.Class(OpenLayers.Popup.AnchoredBubble, {
58
'maxSize': new OpenLayers.Size(100,100)
63
//disable the autosize for the purpose of our matrix
64
OpenLayers.Popup.FramedCloud.prototype.autoSize = false;
66
AutoSizeFramedCloud = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
70
AutoSizeFramedCloudMinSize = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
72
'minSize': new OpenLayers.Size(400,400)
75
AutoSizeFramedCloudMaxSize = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
77
'maxSize': new OpenLayers.Size(100,100)
82
map = new OpenLayers.Map('map');
84
layer = new OpenLayers.Layer.Image(
87
new OpenLayers.Bounds(-82.5,-71.5,97.5,67.5),
88
new OpenLayers.Size(1024,768)
92
markers = new OpenLayers.Layer.Markers("zibo");
93
map.addLayer(markers);
95
map.addControl(new OpenLayers.Control.LayerSwitcher());
96
map.zoomToMaxExtent();
101
function addMarkers() {
103
var ll, popupClass, popupContentHTML;
106
//Anchored NO OVERFLOW
109
//anchored popup small contents no autosize
110
ll = new OpenLayers.LonLat(-55,20);
111
popupClass = OpenLayers.Popup.Anchored;
112
popupContentHTML = '<img src="small.jpg"></img>';
113
addMarker(ll, popupClass, popupContentHTML);
115
//anchored popup small contents no autosize closebox
116
var ll = new OpenLayers.LonLat(-50,20);
117
popupClass = OpenLayers.Popup.Anchored;
118
popupContentHTML = '<img src="small.jpg"></img>';
119
addMarker(ll, popupClass, popupContentHTML, true);
122
//anchored popup small contents autosize
123
ll = new OpenLayers.LonLat(-40,20);
124
popupClass = AutoSizeAnchored;
125
popupContentHTML = '<img src="small.jpg"></img>';
126
addMarker(ll, popupClass, popupContentHTML);
128
//anchored popup small contents autosize closebox
129
ll = new OpenLayers.LonLat(-35,20);
130
popupClass = AutoSizeAnchored;
131
popupContentHTML = '<img src="small.jpg"></img>';
132
addMarker(ll, popupClass, popupContentHTML, true);
135
//anchored popup small contents autosize minsize
136
ll = new OpenLayers.LonLat(-25,20);
137
popupClass = AutoSizeAnchoredMinSize;
138
popupContentHTML = '<img src="small.jpg"></img>';
139
addMarker(ll, popupClass, popupContentHTML);
141
//anchored popup small contents autosize minsize closebox
142
ll = new OpenLayers.LonLat(-20,20);
143
popupClass = AutoSizeAnchoredMinSize;
144
popupContentHTML = '<img src="small.jpg"></img>';
145
addMarker(ll, popupClass, popupContentHTML, true);
148
//anchored popup small contents autosize maxsize
149
ll = new OpenLayers.LonLat(-10,20);
150
popupClass = AutoSizeAnchoredMaxSize;
151
popupContentHTML = '<img src="small.jpg"></img>';
152
addMarker(ll, popupClass, popupContentHTML);
154
//anchored popup small contents autosize maxsize closebox
155
ll = new OpenLayers.LonLat(-5,20);
156
popupClass = AutoSizeAnchoredMaxSize;
157
popupContentHTML = '<img src="small.jpg"></img>';
158
addMarker(ll, popupClass, popupContentHTML, true);
161
//anchored popup bigger contents autosize
162
ll = new OpenLayers.LonLat(5,20);
163
popupClass = AutoSizeAnchored;
164
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>' + samplePopupContentsHTML + '</div>'
165
addMarker(ll, popupClass, popupContentHTML);
167
//anchored popup bigger contents autosize closebox
168
ll = new OpenLayers.LonLat(10,20);
169
popupClass = AutoSizeAnchored;
170
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>closebox<br>' + samplePopupContentsHTML + '</div>'
171
addMarker(ll, popupClass, popupContentHTML, true);
173
//anchored popup wide short text contents autosize
174
ll = new OpenLayers.LonLat(20,20);
175
popupClass = AutoSizeAnchored;
176
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize - wide short text<br>' + samplePopupContentsHTML_WideShort + '</div>'
177
addMarker(ll, popupClass, popupContentHTML);
179
//anchored popup wide short text contents autosize closebox
180
ll = new OpenLayers.LonLat(25,20);
181
popupClass = AutoSizeAnchored;
182
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize - wide short text<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>'
183
addMarker(ll, popupClass, popupContentHTML, true);
186
//anchored popup wide short fixed contents autosize
187
ll = new OpenLayers.LonLat(35,20);
188
popupClass = AutoSizeAnchored;
189
popupContentHTML = '<img src="wideshort.jpg"></img>';
190
addMarker(ll, popupClass, popupContentHTML);
192
//anchored popup wide short fixed contents autosize closebox
193
ll = new OpenLayers.LonLat(40,20);
194
popupClass = AutoSizeAnchored;
195
popupContentHTML = '<img src="wideshort.jpg"></img>';
196
addMarker(ll, popupClass, popupContentHTML, true);
199
//anchored popup thin long fixed contents autosize
200
ll = new OpenLayers.LonLat(50,20);
201
popupClass = AutoSizeAnchored;
202
popupContentHTML = '<img src="thinlong.jpg"></img>';
203
addMarker(ll, popupClass, popupContentHTML);
205
//anchored popup thin long fixed contents autosize closebox
206
ll = new OpenLayers.LonLat(55,20);
207
popupClass = AutoSizeAnchored;
208
popupContentHTML = '<img src="thinlong.jpg"></img>';
209
addMarker(ll, popupClass, popupContentHTML, true);
212
//anchored popup wide long fixed contents autosize
213
ll = new OpenLayers.LonLat(65,20);
214
popupClass = AutoSizeAnchored;
215
popupContentHTML = '<img src="widelong.jpg"></img>'
216
addMarker(ll, popupClass, popupContentHTML);
218
//anchored popup wide long fixed contents autosize closebox
219
ll = new OpenLayers.LonLat(70,20);
220
popupClass = AutoSizeAnchored;
221
popupContentHTML = '<img src="widelong.jpg"></img>'
222
addMarker(ll, popupClass, popupContentHTML, true);
225
//Anchored WITH OVERFLOW
228
//anchored popup small contents no autosize overflow
229
var ll = new OpenLayers.LonLat(-55,15);
230
popupClass = OpenLayers.Popup.Anchored;
231
popupContentHTML = '<img src="small.jpg"></img>';
232
addMarker(ll, popupClass, popupContentHTML, false, true);
234
//anchored popup small contents no autosize closebox overflow
235
var ll = new OpenLayers.LonLat(-50,15);
236
popupClass = OpenLayers.Popup.Anchored;
237
popupContentHTML = '<img src="small.jpg"></img>';
238
addMarker(ll, popupClass, popupContentHTML, true, true);
241
//anchored popup small contents autosize overflow
242
ll = new OpenLayers.LonLat(-40,15);
243
popupClass = AutoSizeAnchored;
244
popupContentHTML = '<img src="small.jpg"></img>';
245
addMarker(ll, popupClass, popupContentHTML, false, true);
247
//anchored popup small contents autosize closebox overflow
248
ll = new OpenLayers.LonLat(-35,15);
249
popupClass = AutoSizeAnchored;
250
popupContentHTML = '<img src="small.jpg"></img>';
251
addMarker(ll, popupClass, popupContentHTML, true, true);
254
//anchored popup small contents autosize minsize overflow
255
ll = new OpenLayers.LonLat(-25,15);
256
popupClass = AutoSizeAnchoredMinSize;
257
popupContentHTML = '<img src="small.jpg"></img>';
258
addMarker(ll, popupClass, popupContentHTML, false, true);
260
//anchored popup small contents autosize minsize closebox overflow
261
ll = new OpenLayers.LonLat(-20,15);
262
popupClass = AutoSizeAnchoredMinSize;
263
popupContentHTML = '<img src="small.jpg"></img>';
264
addMarker(ll, popupClass, popupContentHTML, true, true);
267
//anchored popup small contents autosize maxsize overflow
268
ll = new OpenLayers.LonLat(-10,15);
269
popupClass = AutoSizeAnchoredMaxSize;
270
popupContentHTML = '<img src="small.jpg"></img>';
271
addMarker(ll, popupClass, popupContentHTML, false, true);
273
//anchored popup small contents autosize maxsize closebox overflow
274
ll = new OpenLayers.LonLat(-5,15);
275
popupClass = AutoSizeAnchoredMaxSize;
276
popupContentHTML = '<img src="small.jpg"></img>';
277
addMarker(ll, popupClass, popupContentHTML, true, true);
280
//anchored popup bigger contents autosize overflow
281
ll = new OpenLayers.LonLat(5,15);
282
popupClass = AutoSizeAnchored;
283
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>overflow<br>' + samplePopupContentsHTML + '</div>'
284
addMarker(ll, popupClass, popupContentHTML, false, true);
286
//anchored popup bigger contents autosize closebox overflow
287
ll = new OpenLayers.LonLat(10,15);
288
popupClass = AutoSizeAnchored;
289
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>overflow<br>closebox<br>' + samplePopupContentsHTML + '</div>'
290
addMarker(ll, popupClass, popupContentHTML, true, true);
293
//anchored popup wide short text contents autosize overflow
294
ll = new OpenLayers.LonLat(20,15);
295
popupClass = AutoSizeAnchored;
296
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>overflow<br>' + samplePopupContentsHTML_WideShort + '</div>'
297
addMarker(ll, popupClass, popupContentHTML, false, true);
299
//anchored popup wide short text contents autosize closebox overflow
300
ll = new OpenLayers.LonLat(25,15);
301
popupClass = AutoSizeAnchored;
302
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>overflow<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>'
303
addMarker(ll, popupClass, popupContentHTML, true, true);
305
//anchored popup wide short fixed contents autosize overflow
306
ll = new OpenLayers.LonLat(35,15);
307
popupClass = AutoSizeAnchored;
308
popupContentHTML = '<img src="wideshort.jpg"></img>'
309
addMarker(ll, popupClass, popupContentHTML, false, true);
311
//anchored popup wide short fixed contents autosize closebox overflow
312
ll = new OpenLayers.LonLat(40,15);
313
popupClass = AutoSizeAnchored;
314
popupContentHTML = '<img src="wideshort.jpg"></img>'
315
addMarker(ll, popupClass, popupContentHTML, true, true);
318
//anchored popup thin long fixed contents autosize overflow
319
ll = new OpenLayers.LonLat(50,15);
320
popupClass = AutoSizeAnchored;
321
popupContentHTML = '<img src="thinlong.jpg"></img>'
322
addMarker(ll, popupClass, popupContentHTML, false, true);
324
//anchored popup thin long fixed contents autosize closebox overflow
325
ll = new OpenLayers.LonLat(55,15);
326
popupClass = AutoSizeAnchored;
327
popupContentHTML = '<img src="thinlong.jpg"></img>'
328
addMarker(ll, popupClass, popupContentHTML, true, true);
331
//anchored popup wide long fixed contents autosize overflow
332
ll = new OpenLayers.LonLat(65,15);
333
popupClass = AutoSizeAnchored;
334
popupContentHTML = '<img src="widelong.jpg"></img>'
335
addMarker(ll, popupClass, popupContentHTML, false, true);
337
//anchored popup wide long fixed contents autosize closebox overflow
338
ll = new OpenLayers.LonLat(70,15);
339
popupClass = AutoSizeAnchored;
340
popupContentHTML = '<img src="widelong.jpg"></img>'
341
addMarker(ll, popupClass, popupContentHTML, true, true);
348
//anchored bubble popup small contents no autosize
349
var ll = new OpenLayers.LonLat(-55,5);
350
popupClass = OpenLayers.Popup.AnchoredBubble;
351
popupContentHTML = '<img src="small.jpg"></img>';
352
addMarker(ll, popupClass, popupContentHTML, false);
354
//anchored bubble popup small contents no autosize closebox
355
var ll = new OpenLayers.LonLat(-50,5);
356
popupClass = OpenLayers.Popup.AnchoredBubble;
357
popupContentHTML = '<img src="small.jpg"></img>';
358
addMarker(ll, popupClass, popupContentHTML, true);
361
//anchored bubble popup small contents autosize
362
ll = new OpenLayers.LonLat(-40,5);
363
popupClass = AutoSizeAnchoredBubble;
364
popupContentHTML = '<img src="small.jpg"></img>';
365
addMarker(ll, popupClass, popupContentHTML, false);
367
//anchored bubble popup small contents autosize closebox
368
ll = new OpenLayers.LonLat(-35,5);
369
popupClass = AutoSizeAnchoredBubble;
370
popupContentHTML = '<img src="small.jpg"></img>';
371
addMarker(ll, popupClass, popupContentHTML, true);
374
//anchored bubble popup small contents autosize minsize
375
ll = new OpenLayers.LonLat(-25,5);
376
popupClass = AutoSizeAnchoredBubbleMinSize;
377
popupContentHTML = '<img src="small.jpg"></img>';
378
addMarker(ll, popupClass, popupContentHTML, false);
380
//anchored bubble popup small contents autosize minsize closebox
381
ll = new OpenLayers.LonLat(-20,5);
382
popupClass = AutoSizeAnchoredBubbleMinSize;
383
popupContentHTML = '<img src="small.jpg"></img>';
384
addMarker(ll, popupClass, popupContentHTML, true);
387
//anchored bubble popup small contents autosize maxsize
388
ll = new OpenLayers.LonLat(-10,5);
389
popupClass = AutoSizeAnchoredBubbleMaxSize;
390
popupContentHTML = '<img src="small.jpg"></img>';
391
addMarker(ll, popupClass, popupContentHTML, false);
393
//anchored bubble popup small contents autosize maxsize closebox
394
ll = new OpenLayers.LonLat(-5,5);
395
popupClass = AutoSizeAnchoredBubbleMaxSize;
396
popupContentHTML = '<img src="small.jpg"></img>';
397
addMarker(ll, popupClass, popupContentHTML, true);
400
//anchored bubble popup bigger contents autosize closebox
401
ll = new OpenLayers.LonLat(5,5);
402
popupClass = AutoSizeAnchoredBubble;
403
popupContentHTML = '<div style="background-color:red;">Popup.AnchoredBubble<br>autosize<br>' + samplePopupContentsHTML + '</div>'
404
addMarker(ll, popupClass, popupContentHTML, false);
406
//anchored bubble popup bigger contents autosize closebox
407
ll = new OpenLayers.LonLat(10,5);
408
popupClass = AutoSizeAnchoredBubble;
409
popupContentHTML = '<div style="background-color:red;">Popup.AnchoredBubble<br>autosize<br>closebox<br>' + samplePopupContentsHTML + '</div>'
410
addMarker(ll, popupClass, popupContentHTML, true);
413
//anchored bubble popup wide short text contents autosize
414
ll = new OpenLayers.LonLat(20,5);
415
popupClass = AutoSizeAnchoredBubble;
416
popupContentHTML = '<div style="background-color:red;">Popup.AnchoredBubble<br>autosize - wide short text<br>' + samplePopupContentsHTML_WideShort + '</div>'
417
addMarker(ll, popupClass, popupContentHTML);
419
//anchored bubble popup wide short text contents autosize closebox
420
ll = new OpenLayers.LonLat(25,5);
421
popupClass = AutoSizeAnchoredBubble;
422
popupContentHTML = '<div style="background-color:red;">Popup.AnchoredBubble<br>autosize - wide short text<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>'
423
addMarker(ll, popupClass, popupContentHTML, true);
426
//anchored bubble popup wide short fixed contents autosize
427
ll = new OpenLayers.LonLat(35,5);
428
popupClass = AutoSizeAnchoredBubble;
429
popupContentHTML = '<img src="wideshort.jpg"></img>'
430
addMarker(ll, popupClass, popupContentHTML);
432
//anchored bubble popup wide short fixed contents autosize closebox
433
ll = new OpenLayers.LonLat(40,5);
434
popupClass = AutoSizeAnchoredBubble;
435
popupContentHTML = '<img src="wideshort.jpg"></img>'
436
addMarker(ll, popupClass, popupContentHTML, true);
439
//anchored bubble popup thin long fixed contents autosize
440
ll = new OpenLayers.LonLat(50,5);
441
popupClass = AutoSizeAnchoredBubble;
442
popupContentHTML = '<img src="thinlong.jpg"></img>'
443
addMarker(ll, popupClass, popupContentHTML);
445
//anchored bubble popup thin long fixed contents autosize closebox
446
ll = new OpenLayers.LonLat(55,5);
447
popupClass = AutoSizeAnchoredBubble;
448
popupContentHTML = '<img src="thinlong.jpg"></img>'
449
addMarker(ll, popupClass, popupContentHTML, true);
452
//anchored bubble popup wide long fixed contents autosize
453
ll = new OpenLayers.LonLat(65,5);
454
popupClass = AutoSizeAnchoredBubble;
455
popupContentHTML = '<img src="widelong.jpg"></img>'
456
addMarker(ll, popupClass, popupContentHTML);
458
//anchored bubble popup wide long fixed contents autosize closebox
459
ll = new OpenLayers.LonLat(70,5);
460
popupClass = AutoSizeAnchoredBubble;
461
popupContentHTML = '<img src="widelong.jpg"></img>'
462
addMarker(ll, popupClass, popupContentHTML, true);
468
//anchored bubble popup small contents no autosize
469
var ll = new OpenLayers.LonLat(-55,0);
470
popupClass = OpenLayers.Popup.AnchoredBubble;
471
popupContentHTML = '<img src="small.jpg"></img>';
472
addMarker(ll, popupClass, popupContentHTML, false, true);
474
//anchored bubble popup small contents no autosize closebox
475
var ll = new OpenLayers.LonLat(-50,0);
476
popupClass = OpenLayers.Popup.AnchoredBubble;
477
popupContentHTML = '<img src="small.jpg"></img>';
478
addMarker(ll, popupClass, popupContentHTML, true, true);
481
//anchored bubble popup small contents autosize
482
ll = new OpenLayers.LonLat(-40,0);
483
popupClass = AutoSizeAnchoredBubble;
484
popupContentHTML = '<img src="small.jpg"></img>';
485
addMarker(ll, popupClass, popupContentHTML, false, true);
487
//anchored bubble popup small contents autosize closebox
488
ll = new OpenLayers.LonLat(-35,0);
489
popupClass = AutoSizeAnchoredBubble;
490
popupContentHTML = '<img src="small.jpg"></img>';
491
addMarker(ll, popupClass, popupContentHTML, true, true);
494
//anchored bubble popup small contents autosize minsize
495
ll = new OpenLayers.LonLat(-25,0);
496
popupClass = AutoSizeAnchoredBubbleMinSize;
497
popupContentHTML = '<img src="small.jpg"></img>';
498
addMarker(ll, popupClass, popupContentHTML, false, true);
500
//anchored bubble popup small contents autosize minsize closebox
501
ll = new OpenLayers.LonLat(-20,0);
502
popupClass = AutoSizeAnchoredBubbleMinSize;
503
popupContentHTML = '<img src="small.jpg"></img>';
504
addMarker(ll, popupClass, popupContentHTML, true, true);
507
//anchored bubble popup small contents autosize maxsize
508
ll = new OpenLayers.LonLat(-10,0);
509
popupClass = AutoSizeAnchoredBubbleMaxSize;
510
popupContentHTML = '<img src="small.jpg"></img>';
511
addMarker(ll, popupClass, popupContentHTML, false, true);
513
//anchored bubble popup small contents autosize maxsize closebox
514
ll = new OpenLayers.LonLat(-5,0);
515
popupClass = AutoSizeAnchoredBubbleMaxSize;
516
popupContentHTML = '<img src="small.jpg"></img>';
517
addMarker(ll, popupClass, popupContentHTML, true, true);
520
//anchored bubble popup bigger contents autosize closebox
521
ll = new OpenLayers.LonLat(5,0);
522
popupClass = AutoSizeAnchoredBubble;
523
popupContentHTML = '<div style="background-color:red;">Popup.AnchoredBubble<br>autosize<br>overflow<br>' + samplePopupContentsHTML + '</div>'
524
addMarker(ll, popupClass, popupContentHTML, false, true);
526
//anchored bubble popup bigger contents autosize closebox
527
ll = new OpenLayers.LonLat(10,0);
528
popupClass = AutoSizeAnchoredBubble;
529
popupContentHTML = '<div style="background-color:red;">Popup.AnchoredBubble<br>autosize<br>closebox<br>overflow<br>' + samplePopupContentsHTML + '</div>'
530
addMarker(ll, popupClass, popupContentHTML, true, true);
533
//anchored bubble popup wide short contents autosize overflow
534
ll = new OpenLayers.LonLat(20,0);
535
popupClass = AutoSizeAnchoredBubble;
536
popupContentHTML = '<div style="background-color:red;">Popup.AnchoredBubble<br>autosize<br>overflow<br>' + samplePopupContentsHTML_WideShort + '</div>'
537
addMarker(ll, popupClass, popupContentHTML, false, true);
539
//anchored bubble popup wide short contents autosize closebox overflow
540
ll = new OpenLayers.LonLat(25,0);
541
popupClass = AutoSizeAnchoredBubble;
542
popupContentHTML = '<div style="background-color:red;">Popup.AnchoredBubble<br>autosize<br>overflow<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>'
543
addMarker(ll, popupClass, popupContentHTML, true, true);
546
//anchored bubble popup wide short fixed contents autosize overflow
547
ll = new OpenLayers.LonLat(35,0);
548
popupClass = AutoSizeAnchoredBubble;
549
popupContentHTML = '<img src="wideshort.jpg"></img>'
550
addMarker(ll, popupClass, popupContentHTML, false, true);
552
//anchored bubble popup wide short fixed contents autosize closebox overflow
553
ll = new OpenLayers.LonLat(40,0);
554
popupClass = AutoSizeAnchoredBubble;
555
popupContentHTML = '<img src="wideshort.jpg"></img>'
556
addMarker(ll, popupClass, popupContentHTML, true, true);
559
//anchored bubble popup thin long fixed contents autosize overflow
560
ll = new OpenLayers.LonLat(50,0);
561
popupClass = AutoSizeAnchoredBubble;
562
popupContentHTML = '<img src="thinlong.jpg"></img>'
563
addMarker(ll, popupClass, popupContentHTML, false, true);
565
//anchored bubble popup thin long fixed contents autosize closebox overflow
566
ll = new OpenLayers.LonLat(55,0);
567
popupClass = AutoSizeAnchoredBubble;
568
popupContentHTML = '<img src="thinlong.jpg"></img>'
569
addMarker(ll, popupClass, popupContentHTML, true, true);
572
//anchored bubble popup wide long fixed contents autosize overflow
573
ll = new OpenLayers.LonLat(65,0);
574
popupClass = AutoSizeAnchoredBubble;
575
popupContentHTML = '<img src="widelong.jpg"></img>'
576
addMarker(ll, popupClass, popupContentHTML, false, true);
578
//anchored bubble popup wide long fixed contents autosize closebox overflow
579
ll = new OpenLayers.LonLat(70,0);
580
popupClass = AutoSizeAnchoredBubble;
581
popupContentHTML = '<img src="widelong.jpg"></img>'
582
addMarker(ll, popupClass, popupContentHTML, true, true);
590
//anchored bubble popup small contents no autosize
591
var ll = new OpenLayers.LonLat(-55,-15);
592
popupClass = OpenLayers.Popup.FramedCloud;
593
popupContentHTML = '<img src="small.jpg"></img>';
594
addMarker(ll, popupClass, popupContentHTML, false);
596
//anchored bubble popup small contents no autosize closebox
597
var ll = new OpenLayers.LonLat(-50,-15);
598
popupClass = OpenLayers.Popup.FramedCloud;
599
popupContentHTML = '<img src="small.jpg"></img>';
600
addMarker(ll, popupClass, popupContentHTML, true);
603
//anchored bubble popup small contents autosize
604
ll = new OpenLayers.LonLat(-40,-15);
605
popupClass = AutoSizeFramedCloud;
606
popupContentHTML = '<img src="small.jpg"></img>';
607
addMarker(ll, popupClass, popupContentHTML, false);
609
//anchored bubble popup small contents autosize closebox
610
ll = new OpenLayers.LonLat(-35,-15);
611
popupClass = AutoSizeFramedCloud;
612
popupContentHTML = '<img src="small.jpg"></img>';
613
addMarker(ll, popupClass, popupContentHTML, true);
616
//anchored bubble popup small contents autosize minsize
617
ll = new OpenLayers.LonLat(-25,-15);
618
popupClass = AutoSizeFramedCloudMinSize;
619
popupContentHTML = '<img src="small.jpg"></img>';
620
addMarker(ll, popupClass, popupContentHTML, false);
622
//anchored bubble popup small contents autosize minsize closebox
623
ll = new OpenLayers.LonLat(-20,-15);
624
popupClass = AutoSizeFramedCloudMinSize;
625
popupContentHTML = '<img src="small.jpg"></img>';
626
addMarker(ll, popupClass, popupContentHTML, true);
629
//anchored bubble popup small contents autosize maxsize
630
ll = new OpenLayers.LonLat(-10,-15);
631
popupClass = AutoSizeFramedCloudMaxSize;
632
popupContentHTML = '<img src="small.jpg"></img>';
633
addMarker(ll, popupClass, popupContentHTML, false);
635
//anchored bubble popup small contents autosize maxsize closebox
636
ll = new OpenLayers.LonLat(-5,-15);
637
popupClass = AutoSizeFramedCloudMaxSize;
638
popupContentHTML = '<img src="small.jpg"></img>';
639
addMarker(ll, popupClass, popupContentHTML, true);
642
//anchored bubble popup bigger contents autosize closebox
643
ll = new OpenLayers.LonLat(5,-15);
644
popupClass = AutoSizeFramedCloud;
645
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>' + samplePopupContentsHTML + '</div>'
646
addMarker(ll, popupClass, popupContentHTML, false);
648
//anchored bubble popup bigger contents autosize closebox
649
ll = new OpenLayers.LonLat(10,-15);
650
popupClass = AutoSizeFramedCloud;
651
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>closebox<br>' + samplePopupContentsHTML + '</div>'
652
addMarker(ll, popupClass, popupContentHTML, true);
655
//anchored bubble popup wide short text contents autosize
656
ll = new OpenLayers.LonLat(20,-15);
657
popupClass = AutoSizeFramedCloud;
658
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize - wide short text<br>' + samplePopupContentsHTML_WideShort + '</div>'
659
addMarker(ll, popupClass, popupContentHTML);
661
//anchored bubble popup wide short text contents autosize closebox
662
ll = new OpenLayers.LonLat(25,-15);
663
popupClass = AutoSizeFramedCloud;
664
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize - wide short text<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>'
665
addMarker(ll, popupClass, popupContentHTML, true);
668
//anchored bubble popup wide short fixed contents autosize
669
ll = new OpenLayers.LonLat(35,-15);
670
popupClass = AutoSizeFramedCloud;
671
popupContentHTML = '<img src="wideshort.jpg"></img>'
672
addMarker(ll, popupClass, popupContentHTML);
674
//anchored bubble popup wide short fixed contents autosize closebox
675
ll = new OpenLayers.LonLat(40,-15);
676
popupClass = AutoSizeFramedCloud;
677
popupContentHTML = '<img src="wideshort.jpg"></img>'
678
addMarker(ll, popupClass, popupContentHTML, true);
681
//anchored bubble popup thin long fixed contents autosize
682
ll = new OpenLayers.LonLat(50,-15);
683
popupClass = AutoSizeFramedCloud;
684
popupContentHTML = '<img src="thinlong.jpg"></img>'
685
addMarker(ll, popupClass, popupContentHTML);
687
//anchored bubble popup thin long fixed contents autosize closebox
688
ll = new OpenLayers.LonLat(55,-15);
689
popupClass = AutoSizeFramedCloud;
690
popupContentHTML = '<img src="thinlong.jpg"></img>'
691
addMarker(ll, popupClass, popupContentHTML, true);
694
//anchored bubble popup wide long fixed contents autosize
695
ll = new OpenLayers.LonLat(65,-15);
696
popupClass = AutoSizeFramedCloud;
697
popupContentHTML = '<img src="widelong.jpg"></img>'
698
addMarker(ll, popupClass, popupContentHTML);
700
//anchored bubble popup wide long fixed contents autosize closebox
701
ll = new OpenLayers.LonLat(70,-15);
702
popupClass = AutoSizeFramedCloud;
703
popupContentHTML = '<img src="widelong.jpg"></img>'
704
addMarker(ll, popupClass, popupContentHTML, true);
710
//anchored bubble popup small contents no autosize
711
var ll = new OpenLayers.LonLat(-55,-20);
712
popupClass = OpenLayers.Popup.FramedCloud;
713
popupContentHTML = '<img src="small.jpg"></img>';
714
addMarker(ll, popupClass, popupContentHTML, false, true);
716
//anchored bubble popup small contents no autosize closebox
717
var ll = new OpenLayers.LonLat(-50,-20);
718
popupClass = OpenLayers.Popup.FramedCloud;
719
popupContentHTML = '<img src="small.jpg"></img>';
720
addMarker(ll, popupClass, popupContentHTML, true, true);
723
//anchored bubble popup small contents autosize
724
ll = new OpenLayers.LonLat(-40,-20);
725
popupClass = AutoSizeFramedCloud;
726
popupContentHTML = '<img src="small.jpg"></img>';
727
addMarker(ll, popupClass, popupContentHTML, false, true);
729
//anchored bubble popup small contents autosize closebox
730
ll = new OpenLayers.LonLat(-35,-20);
731
popupClass = AutoSizeFramedCloud;
732
popupContentHTML = '<img src="small.jpg"></img>';
733
addMarker(ll, popupClass, popupContentHTML, true, true);
736
//anchored bubble popup small contents autosize minsize
737
ll = new OpenLayers.LonLat(-25,-20);
738
popupClass = AutoSizeFramedCloudMinSize;
739
popupContentHTML = '<img src="small.jpg"></img>';
740
addMarker(ll, popupClass, popupContentHTML, false, true);
742
//anchored bubble popup small contents autosize minsize closebox
743
ll = new OpenLayers.LonLat(-20,-20);
744
popupClass = AutoSizeFramedCloudMinSize;
745
popupContentHTML = '<img src="small.jpg"></img>';
746
addMarker(ll, popupClass, popupContentHTML, true, true);
749
//anchored bubble popup small contents autosize maxsize
750
ll = new OpenLayers.LonLat(-10,-20);
751
popupClass = AutoSizeFramedCloudMaxSize;
752
popupContentHTML = '<img src="small.jpg"></img>';
753
addMarker(ll, popupClass, popupContentHTML, false, true);
755
//anchored bubble popup small contents autosize maxsize closebox
756
ll = new OpenLayers.LonLat(-5,-20);
757
popupClass = AutoSizeFramedCloudMaxSize;
758
popupContentHTML = '<img src="small.jpg"></img>';
759
addMarker(ll, popupClass, popupContentHTML, true, true);
762
//anchored bubble popup bigger contents autosize closebox
763
ll = new OpenLayers.LonLat(5,-20);
764
popupClass = AutoSizeFramedCloud;
765
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>overflow<br>' + samplePopupContentsHTML + '</div>'
766
addMarker(ll, popupClass, popupContentHTML, false, true);
768
//anchored bubble popup bigger contents autosize closebox
769
ll = new OpenLayers.LonLat(10,-20);
770
popupClass = AutoSizeFramedCloud;
771
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>closebox<br>overflow<br>' + samplePopupContentsHTML + '</div>'
772
addMarker(ll, popupClass, popupContentHTML, true, true);
775
//anchored bubble popup wide short contents autosize overflow
776
ll = new OpenLayers.LonLat(20,-20);
777
popupClass = AutoSizeFramedCloud;
778
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>overflow<br>' + samplePopupContentsHTML_WideShort + '</div>'
779
addMarker(ll, popupClass, popupContentHTML, false, true);
781
//anchored bubble popup wide short contents autosize closebox overflow
782
ll = new OpenLayers.LonLat(25,-20);
783
popupClass = AutoSizeFramedCloud;
784
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>overflow<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>'
785
addMarker(ll, popupClass, popupContentHTML, true, true);
788
//anchored bubble popup wide short fixed contents autosize overflow
789
ll = new OpenLayers.LonLat(35,-20);
790
popupClass = AutoSizeFramedCloud;
791
popupContentHTML = '<img src="wideshort.jpg"></img>'
792
addMarker(ll, popupClass, popupContentHTML, false, true);
794
//anchored bubble popup wide short fixed contents autosize closebox overflow
795
ll = new OpenLayers.LonLat(40,-20);
796
popupClass = AutoSizeFramedCloud;
797
popupContentHTML = '<img src="wideshort.jpg"></img>'
798
addMarker(ll, popupClass, popupContentHTML, true, true);
801
//anchored bubble popup thin long fixed contents autosize overflow
802
ll = new OpenLayers.LonLat(50,-20);
803
popupClass = AutoSizeFramedCloud;
804
popupContentHTML = '<img src="thinlong.jpg"></img>'
805
addMarker(ll, popupClass, popupContentHTML, false, true);
807
//anchored bubble popup thin long fixed contents autosize closebox overflow
808
ll = new OpenLayers.LonLat(55,-20);
809
popupClass = AutoSizeFramedCloud;
810
popupContentHTML = '<img src="thinlong.jpg"></img>'
811
addMarker(ll, popupClass, popupContentHTML, true, true);
814
//anchored bubble popup wide long fixed contents autosize overflow
815
ll = new OpenLayers.LonLat(65,-20);
816
popupClass = AutoSizeFramedCloud;
817
popupContentHTML = '<img src="widelong.jpg"></img>'
818
addMarker(ll, popupClass, popupContentHTML, false, true);
820
//anchored bubble popup wide long fixed contents autosize closebox overflow
821
ll = new OpenLayers.LonLat(70,-20);
822
popupClass = AutoSizeFramedCloud;
823
popupContentHTML = '<img src="widelong.jpg"></img>'
824
addMarker(ll, popupClass, popupContentHTML, true, true);
830
* Function: addMarker
831
* Add a new marker to the markers layer given the following lonlat,
832
* popupClass, and popup contents HTML. Also allow specifying
833
* whether or not to give the popup a close box.
836
* ll - {<OpenLayers.LonLat>} Where to place the marker
837
* popupClass - {<OpenLayers.Class>} Which class of popup to bring up
838
* when the marker is clicked.
839
* popupContentHTML - {String} What to put in the popup
840
* closeBox - {Boolean} Should popup have a close box?
841
* overflow - {Boolean} Let the popup overflow scrollbars?
843
function addMarker(ll, popupClass, popupContentHTML, closeBox, overflow) {
845
var feature = new OpenLayers.Feature(markers, ll);
846
feature.closeBox = closeBox;
847
feature.popupClass = popupClass;
848
feature.data.popupContentHTML = popupContentHTML;
849
feature.data.overflow = (overflow) ? "auto" : "hidden";
851
var marker = feature.createMarker();
853
var markerClick = function (evt) {
854
if (this.popup == null) {
855
this.popup = this.createPopup(this.closeBox);
856
map.addPopup(this.popup);
861
currentPopup = this.popup;
862
OpenLayers.Event.stop(evt);
864
marker.events.register("mousedown", feature, markerClick);
866
markers.addMarker(marker);
871
<body onload="init()">
872
<h1 id="title">Popup Matrix</h1>
877
All kinds of different popup configurations.
880
<div id="map" class="smallmap"></div>
882
<!-- preloading these images so the autosize will work correctly -->
883
<img src="wideshort.jpg" style="position:absolute; top:-5000px; left: -5000px"></img>
884
<img src="widelong.jpg" style="position:absolute; top:-5000px; left: -5000px"></img>
885
<img src="thinlong.jpg" style="position:absolute; top:-5000px; left: -5000px"></img>
887
<p> All of the images in this file a pre-cached, meaning they are
888
loaded immediately when you load the page (they are just placed
889
far offscreen, that's why you don't see them).
892
<p> The only image that is *not* preloaded is small.jpg, the brazilian
893
flag. We do this in order to test out to make sure that our auto-sizing
894
code does in fact activate itself as the images load. To verify
895
this, clear your cache and reload this example page. Click on
896
any of the markers in the 'AutoSize' row. If the popup autosizes
897
to correctly contain the entire flag: golden. If the popup is
898
tiny and you can only see a corner of it, then this code is broken.