1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
|
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers: Popup Mayhem</title>
<link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
#map {
width: 900px;
height: 500px;
border: 1px solid black;
background-color: blue;
}
</style>
<script src="Firebug/firebug.js"></script>
<script src="openlayers/OpenLayers.js"></script>
<script type="text/javascript">
var map;
var layer, markers;
var currentPopup;
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>";
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.";
// different popup types
//anchored
AutoSizeAnchored = OpenLayers.Class(OpenLayers.Popup.Anchored, {
'autoSize': true
});
AutoSizeAnchoredMinSize = OpenLayers.Class(OpenLayers.Popup.Anchored, {
'autoSize': true,
'minSize': new OpenLayers.Size(400,400)
});
AutoSizeAnchoredMaxSize = OpenLayers.Class(OpenLayers.Popup.Anchored, {
'autoSize': true,
'maxSize': new OpenLayers.Size(100,100)
});
//framed
//disable the autosize for the purpose of our matrix
OpenLayers.Popup.FramedCloud.prototype.autoSize = false;
AutoSizeFramedCloud = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true
});
AutoSizeFramedCloudMinSize = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true,
'minSize': new OpenLayers.Size(400,400)
});
AutoSizeFramedCloudMaxSize = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true,
'maxSize': new OpenLayers.Size(100,100)
});
function init(){
map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.Image(
"popupMatrix",
"img/popupMatrix.jpg",
new OpenLayers.Bounds(-82.5,-71.5,97.5,67.5),
new OpenLayers.Size(1024,768)
);
map.addLayer(layer);
markers = new OpenLayers.Layer.Markers("zibo");
map.addLayer(markers);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
addMarkers();
}
function addMarkers() {
var ll, popupClass, popupContentHTML;
//
//Anchored NO OVERFLOW
//
//anchored popup small contents no autosize
ll = new OpenLayers.LonLat(-55,20);
popupClass = OpenLayers.Popup.Anchored;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored popup small contents no autosize closebox
var ll = new OpenLayers.LonLat(-50,20);
popupClass = OpenLayers.Popup.Anchored;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored popup small contents autosize
ll = new OpenLayers.LonLat(-40,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored popup small contents autosize closebox
ll = new OpenLayers.LonLat(-35,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored popup small contents autosize minsize
ll = new OpenLayers.LonLat(-25,20);
popupClass = AutoSizeAnchoredMinSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored popup small contents autosize minsize closebox
ll = new OpenLayers.LonLat(-20,20);
popupClass = AutoSizeAnchoredMinSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored popup small contents autosize maxsize
ll = new OpenLayers.LonLat(-10,20);
popupClass = AutoSizeAnchoredMaxSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored popup small contents autosize maxsize closebox
ll = new OpenLayers.LonLat(-5,20);
popupClass = AutoSizeAnchoredMaxSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored popup bigger contents autosize
ll = new OpenLayers.LonLat(5,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>' + samplePopupContentsHTML + '</div>';
addMarker(ll, popupClass, popupContentHTML);
//anchored popup bigger contents autosize closebox
ll = new OpenLayers.LonLat(10,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>closebox<br>' + samplePopupContentsHTML + '</div>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored popup wide short text contents autosize
ll = new OpenLayers.LonLat(20,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize - wide short text<br>' + samplePopupContentsHTML_WideShort + '</div>';
addMarker(ll, popupClass, popupContentHTML);
//anchored popup wide short text contents autosize closebox
ll = new OpenLayers.LonLat(25,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize - wide short text<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored popup wide short fixed contents autosize
ll = new OpenLayers.LonLat(35,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/wideshort.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored popup wide short fixed contents autosize closebox
ll = new OpenLayers.LonLat(40,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/wideshort.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored popup thin long fixed contents autosize
ll = new OpenLayers.LonLat(50,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/thinlong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored popup thin long fixed contents autosize closebox
ll = new OpenLayers.LonLat(55,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/thinlong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored popup wide long fixed contents autosize
ll = new OpenLayers.LonLat(65,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/widelong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored popup wide long fixed contents autosize closebox
ll = new OpenLayers.LonLat(70,20);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/widelong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//
//Anchored WITH OVERFLOW
//
//anchored popup small contents no autosize overflow
var ll = new OpenLayers.LonLat(-55,15);
popupClass = OpenLayers.Popup.Anchored;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored popup small contents no autosize closebox overflow
var ll = new OpenLayers.LonLat(-50,15);
popupClass = OpenLayers.Popup.Anchored;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored popup small contents autosize overflow
ll = new OpenLayers.LonLat(-40,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored popup small contents autosize closebox overflow
ll = new OpenLayers.LonLat(-35,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored popup small contents autosize minsize overflow
ll = new OpenLayers.LonLat(-25,15);
popupClass = AutoSizeAnchoredMinSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored popup small contents autosize minsize closebox overflow
ll = new OpenLayers.LonLat(-20,15);
popupClass = AutoSizeAnchoredMinSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored popup small contents autosize maxsize overflow
ll = new OpenLayers.LonLat(-10,15);
popupClass = AutoSizeAnchoredMaxSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored popup small contents autosize maxsize closebox overflow
ll = new OpenLayers.LonLat(-5,15);
popupClass = AutoSizeAnchoredMaxSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored popup bigger contents autosize overflow
ll = new OpenLayers.LonLat(5,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>overflow<br>' + samplePopupContentsHTML + '</div>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored popup bigger contents autosize closebox overflow
ll = new OpenLayers.LonLat(10,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>overflow<br>closebox<br>' + samplePopupContentsHTML + '</div>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored popup wide short text contents autosize overflow
ll = new OpenLayers.LonLat(20,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>overflow<br>' + samplePopupContentsHTML_WideShort + '</div>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored popup wide short text contents autosize closebox overflow
ll = new OpenLayers.LonLat(25,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<div style="background-color:red;">Popup.Anchored<br>autosize<br>overflow<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored popup wide short fixed contents autosize overflow
ll = new OpenLayers.LonLat(35,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/wideshort.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored popup wide short fixed contents autosize closebox overflow
ll = new OpenLayers.LonLat(40,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/wideshort.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored popup thin long fixed contents autosize overflow
ll = new OpenLayers.LonLat(50,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/thinlong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored popup thin long fixed contents autosize closebox overflow
ll = new OpenLayers.LonLat(55,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/thinlong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored popup wide long fixed contents autosize overflow
ll = new OpenLayers.LonLat(65,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/widelong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored popup wide long fixed contents autosize closebox overflow
ll = new OpenLayers.LonLat(70,15);
popupClass = AutoSizeAnchored;
popupContentHTML = '<img src="img/widelong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//FRAMED
//
//FRAMED NO OVERFLOW
//
//anchored bubble popup small contents no autosize
var ll = new OpenLayers.LonLat(-55,-15);
popupClass = OpenLayers.Popup.FramedCloud;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false);
//anchored bubble popup small contents no autosize closebox
var ll = new OpenLayers.LonLat(-50,-15);
popupClass = OpenLayers.Popup.FramedCloud;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored bubble popup small contents autosize
ll = new OpenLayers.LonLat(-40,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false);
//anchored bubble popup small contents autosize closebox
ll = new OpenLayers.LonLat(-35,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored bubble popup small contents autosize minsize
ll = new OpenLayers.LonLat(-25,-15);
popupClass = AutoSizeFramedCloudMinSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false);
//anchored bubble popup small contents autosize minsize closebox
ll = new OpenLayers.LonLat(-20,-15);
popupClass = AutoSizeFramedCloudMinSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored bubble popup small contents autosize maxsize
ll = new OpenLayers.LonLat(-10,-15);
popupClass = AutoSizeFramedCloudMaxSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false);
//anchored bubble popup small contents autosize maxsize closebox
ll = new OpenLayers.LonLat(-5,-15);
popupClass = AutoSizeFramedCloudMaxSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored bubble popup bigger contents autosize closebox
ll = new OpenLayers.LonLat(5,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>' + samplePopupContentsHTML + '</div>';
addMarker(ll, popupClass, popupContentHTML, false);
//anchored bubble popup bigger contents autosize closebox
ll = new OpenLayers.LonLat(10,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>closebox<br>' + samplePopupContentsHTML + '</div>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored bubble popup wide short text contents autosize
ll = new OpenLayers.LonLat(20,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize - wide short text<br>' + samplePopupContentsHTML_WideShort + '</div>';
addMarker(ll, popupClass, popupContentHTML);
//anchored bubble popup wide short text contents autosize closebox
ll = new OpenLayers.LonLat(25,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize - wide short text<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored bubble popup wide short fixed contents autosize
ll = new OpenLayers.LonLat(35,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/wideshort.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored bubble popup wide short fixed contents autosize closebox
ll = new OpenLayers.LonLat(40,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/wideshort.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored bubble popup thin long fixed contents autosize
ll = new OpenLayers.LonLat(50,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/thinlong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored bubble popup thin long fixed contents autosize closebox
ll = new OpenLayers.LonLat(55,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/thinlong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//anchored bubble popup wide long fixed contents autosize
ll = new OpenLayers.LonLat(65,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/widelong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML);
//anchored bubble popup wide long fixed contents autosize closebox
ll = new OpenLayers.LonLat(70,-15);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/widelong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true);
//
//FRAMED OVERFLOW
//
//anchored bubble popup small contents no autosize
var ll = new OpenLayers.LonLat(-55,-20);
popupClass = OpenLayers.Popup.FramedCloud;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored bubble popup small contents no autosize closebox
var ll = new OpenLayers.LonLat(-50,-20);
popupClass = OpenLayers.Popup.FramedCloud;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored bubble popup small contents autosize
ll = new OpenLayers.LonLat(-40,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored bubble popup small contents autosize closebox
ll = new OpenLayers.LonLat(-35,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored bubble popup small contents autosize minsize
ll = new OpenLayers.LonLat(-25,-20);
popupClass = AutoSizeFramedCloudMinSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored bubble popup small contents autosize minsize closebox
ll = new OpenLayers.LonLat(-20,-20);
popupClass = AutoSizeFramedCloudMinSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored bubble popup small contents autosize maxsize
ll = new OpenLayers.LonLat(-10,-20);
popupClass = AutoSizeFramedCloudMaxSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored bubble popup small contents autosize maxsize closebox
ll = new OpenLayers.LonLat(-5,-20);
popupClass = AutoSizeFramedCloudMaxSize;
popupContentHTML = '<img src="img/small.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored bubble popup bigger contents autosize closebox
ll = new OpenLayers.LonLat(5,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>overflow<br>' + samplePopupContentsHTML + '</div>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored bubble popup bigger contents autosize closebox
ll = new OpenLayers.LonLat(10,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>closebox<br>overflow<br>' + samplePopupContentsHTML + '</div>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored bubble popup wide short contents autosize overflow
ll = new OpenLayers.LonLat(20,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>overflow<br>' + samplePopupContentsHTML_WideShort + '</div>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored bubble popup wide short contents autosize closebox overflow
ll = new OpenLayers.LonLat(25,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<div style="background-color:red;">Popup.FramedCloud<br>autosize<br>overflow<br>closebox<br>' + samplePopupContentsHTML_WideShort + '</div>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored bubble popup wide short fixed contents autosize overflow
ll = new OpenLayers.LonLat(35,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/wideshort.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored bubble popup wide short fixed contents autosize closebox overflow
ll = new OpenLayers.LonLat(40,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/wideshort.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored bubble popup thin long fixed contents autosize overflow
ll = new OpenLayers.LonLat(50,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/thinlong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored bubble popup thin long fixed contents autosize closebox overflow
ll = new OpenLayers.LonLat(55,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/thinlong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
//anchored bubble popup wide long fixed contents autosize overflow
ll = new OpenLayers.LonLat(65,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/widelong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, false, true);
//anchored bubble popup wide long fixed contents autosize closebox overflow
ll = new OpenLayers.LonLat(70,-20);
popupClass = AutoSizeFramedCloud;
popupContentHTML = '<img src="img/widelong.jpg"></img>';
addMarker(ll, popupClass, popupContentHTML, true, true);
}
/**
* Function: addMarker
* Add a new marker to the markers layer given the following lonlat,
* popupClass, and popup contents HTML. Also allow specifying
* whether or not to give the popup a close box.
*
* Parameters:
* ll - {<OpenLayers.LonLat>} Where to place the marker
* popupClass - {<OpenLayers.Class>} Which class of popup to bring up
* when the marker is clicked.
* popupContentHTML - {String} What to put in the popup
* closeBox - {Boolean} Should popup have a close box?
* overflow - {Boolean} Let the popup overflow scrollbars?
*/
function addMarker(ll, popupClass, popupContentHTML, closeBox, overflow) {
var feature = new OpenLayers.Feature(markers, ll);
feature.closeBox = closeBox;
feature.popupClass = popupClass;
feature.data.popupContentHTML = popupContentHTML;
feature.data.overflow = (overflow) ? "auto" : "hidden";
var marker = feature.createMarker();
var markerClick = function (evt) {
if (this.popup == null) {
this.popup = this.createPopup(this.closeBox);
map.addPopup(this.popup);
this.popup.show();
} else {
this.popup.toggle();
}
currentPopup = this.popup;
OpenLayers.Event.stop(evt);
};
marker.events.register("mousedown", feature, markerClick);
markers.addMarker(marker);
}
</script>
</head>
<body onload="init()">
<h1 id="title">Popup Matrix</h1>
<div id="tags">
popup, popups
</div>
<p id="shortdesc">
All kinds of different popup configurations.
</p>
<div id="map" class="smallmap"></div>
<!-- preloading these images so the autosize will work correctly -->
<img src="img/wideshort.jpg" style="position:absolute; top:-5000px; left: -5000px"></img>
<img src="img/widelong.jpg" style="position:absolute; top:-5000px; left: -5000px"></img>
<img src="img/thinlong.jpg" style="position:absolute; top:-5000px; left: -5000px"></img>
<p> All of the images in this file a pre-cached, meaning they are
loaded immediately when you load the page (they are just placed
far offscreen, that's why you don't see them).
</p>
<br>
<p> The only image that is *not* preloaded is img/small.jpg, the brazilian
flag. We do this in order to test out to make sure that our auto-sizing
code does in fact activate itself as the images load. To verify
this, clear your cache and reload this example page. Click on
any of the markers in the 'AutoSize' row. If the popup autosizes
to correctly contain the entire flag: golden. If the popup is
tiny and you can only see a corner of it, then this code is broken.
</p>
<br>
</div>
</body>
</html>
|