1/* 2 * Copyright (c) 2008-2011 Mark C. Prins <mc.prins@gmail.com> 3 * 4 * Permission to use, copy, modify, and distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17/** 18 * @fileoverview Javascript voor OpenLayers plugin. 19 * 20 * @requires {lib/OpenLayers.js} or other full openlayers build 21 * @author Mark C. Prins <mc.prins@gmail.com> 22 * 23 */ 24 25/** 26 * Openlayers selectcontrol. 27 * 28 * @type {OpenLayers.Control.SelectFeature} 29 * @private 30 */ 31var selectControl, 32/** 33 * Openlayers bounds used for managing the map extent. 34 * 35 * @type {OpenLayers.Bounds} 36 * @private 37 */ 38extent; 39 40/** 41 * handle feature select event. 42 * 43 * @param {OpenLayers.Feature.Vector} 44 * the selected feature 45 */ 46function onFeatureSelect(feature) { 47 var selectedFeature = feature; 48 // 'this' is selectFeature control 49 var pPos = selectedFeature.geometry.getBounds().getCenterLonLat(); 50 // != OpenLayers.Geometry.Point 51 if (selectedFeature.geometry.CLASS_NAME === "OpenLayers.Geometry.LineString") { 52 try { 53 // for lines make the popup show at the cursor position 54 pPos = feature.layer.map 55 .getLonLatFromViewPortPx(this.handlers.feature.evt.xy); 56 } catch (anErr) { 57 OpenLayers.Console.warn("unable to get event position; reverting to boundingbox center."); 58 pPos = selectedFeature.geometry.getBounds().getCenterLonLat(); 59 } 60 } 61 62 var pContent = ""; 63 if (feature.data.rowId !== undefined) { 64 pContent += "<span style=''>" + feature.data.rowId + ": </span>"; 65 } 66 if (feature.data.name !== undefined) { 67 pContent += "<div style=''>" + feature.data.name + "<br /></div>"; 68 } 69 if (feature.data.ele !== undefined) { 70 pContent += "<div style=''>elevation: " + feature.data.ele 71 + "<br /></div>"; 72 } 73 if (feature.data.type !== undefined) { 74 pContent += "<div style=''>" + feature.data.type + "<br /></div>"; 75 } 76 if (feature.data.time !== undefined) { 77 pContent += "<div style=''>time: " + feature.data.time + "<br /></div>"; 78 } 79 if (feature.data.description !== undefined) { 80 pContent += "<div style=''>" + feature.data.description + "</div>"; 81 } 82 83 if (pContent.length > 0) { 84 var popup = new OpenLayers.Popup.FramedCloud("olPopup", pPos, null, 85 pContent, null, true, function() { 86 selectControl.unselect(selectedFeature); 87 }); 88 feature.popup = popup; 89 feature.layer.map.addPopup(popup); 90 } 91} 92 93/** 94 * handle feature unselect event. remove & destroy the popup. 95 * 96 * @param {OpenLayers.Feature.Vector} 97 * the un-selected feature 98 */ 99function onFeatureUnselect(feature) { 100 if (feature.popup !== null) { 101 feature.layer.map.removePopup(feature.popup); 102 feature.popup.destroy(); 103 feature.popup = null; 104 } 105} 106 107/** init. */ 108function olInit() { 109 // iterator 110 var _i = 0; 111 // hide the table with POI by giving it a print only style 112 var tbls = getElementsByClass('olPOItableSpan', null, null); 113 for (_i = 0; _i < tbls.length; _i++) { 114 // tbls[i].style.display = 'none'; 115 tbls[_i].className += ' olPrintOnly'; 116 } 117 // hide the static map image by giving it a print only style 118 var statImgs = getElementsByClass('olStaticMap', null, null); 119 for (_i = 0; _i < statImgs.length; _i++) { 120 // statImgs[i].style.display = 'none'; 121 statImgs[_i].className += ' olPrintOnly'; 122 } 123 // show the dynamic map but only in the browser, this element is not here 124 // when we load the page 125 // var dynMaps = getElementsByClass('olContainer', null, null); 126 // for (_i = 0; _i < dynMaps.length; _i++) { 127 // // dynMaps[i].style.display = 'inline'; 128 // dynMaps[_i].className += ' olWebOnly'; 129 // } 130} 131 132/** 133 * creates a DocumentFragment to insert into the dom. 134 * 135 * @param mapid 136 * id for the map div 137 * @param width 138 * width for the map div 139 * @param height 140 * height for the map div 141 * @returns a {DocumentFragment} element that can be injected into the dom 142 */ 143function olCreateMaptag(mapid, width, height) { 144 var mEl = '<div id="olContainer" class="olContainer olWebOnly">' 145 + '<div id="' 146 + mapid 147 + '-olToolbar" class="olToolbar"></div>' 148 + '<div class="olClearBoth"></div>' 149 + '<div id="' 150 + mapid 151 + '" style="width:' 152 + width 153 + ';height:' 154 + height 155 + ';" class="olMap"></div>' 156 + '<div id="' 157 + mapid 158 + '-olStatusBar" class="olStatusBarContainer">' 159 + '<div id="' 160 + mapid 161 + '-statusbar-scale" class="olStatusBar olStatusBarScale">scale</div>' 162 + '<div id="' 163 + mapid 164 + '-statusbar-link" class="olStatusBar olStatusBarPermalink"><a href="" id="' 165 + mapid 166 + '-statusbar-link-ref">map link</a></div>' 167 + '<div id="' 168 + mapid 169 + '-statusbar-mouseposition" class="olStatusBar olStatusBarMouseposition"></div>' 170 + '<div id="' 171 + mapid 172 + '-statusbar-projection" class="olStatusBar olStatusBarProjection">proj</div>' 173 + '<div id="' 174 + mapid 175 + '-statusbar-text" class="olStatusBar olStatusBarText">txt</div>' 176 + '</div>\n</div>', 177 // fragment 178 frag = document.createDocumentFragment(), 179 // temp node 180 temp = document.createElement('div'); 181 temp.innerHTML = mEl; 182 while (temp.firstChild) { 183 frag.appendChild(temp.firstChild); 184 } 185 return frag; 186} 187 188/** 189 * create the map based on the params given. 190 * 191 * @param {Object}mapOpts 192 * MapOptions hash {id:'olmap', width:500px, height:500px, lat:6710200, lon:506500, zoom:13, 193 * toolbar:1, statusbar:1, controls:1, poihoverstyle:1, baselyr:'', 194 * kmlfile:'', gpxfile:'', summary:''} 195 * @param {Array}OLmapPOI 196 * array with POI's [ {lat:6710300,lon:506000,txt:'instap 197 * punt',angle:180,opacity:.9,img:'', rowId:n},... ]); 198 * 199 */ 200function createMap(mapOpts, OLmapPOI) { 201 if (!olEnable) { 202 return; 203 } 204 205 var DocBase = DOKU_BASE; 206 207 OpenLayers.IMAGE_RELOAD_ATTEMPTS = 4; 208 OpenLayers.Util.onImageLoadErrorColor = 'pink'; 209 OpenLayers.Util.onImageLoadError = function() { 210 /* transparent gif */ 211 // IE 8 complains w/ stack overflow... this.src = 212 // "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="; 213 this.src = DocBase + "lib/plugins/openlayersmap/lib/img/blank.gif"; 214 }; 215 // http://mapbox.com/documentation/adding-tiles-your-site/openlayers-themes 216 // OpenLayers.ImgPath = ''; 217 218 // find map element 219 var cleartag = document.getElementById(mapOpts.id + '-clearer'); 220 if (cleartag === null) { 221 return; 222 } 223 224 var fragment = olCreateMaptag(mapOpts.id, mapOpts.width, mapOpts.height); 225 cleartag.parentNode.insertBefore(fragment, cleartag); 226 227 /** dynamic map extent. */ 228 var extent = new OpenLayers.Bounds(), 229 230 /** map. */ 231 m = new OpenLayers.Map(mapOpts.id, { 232 projection : new OpenLayers.Projection("EPSG:900913"), 233 displayProjection : new OpenLayers.Projection("EPSG:4326"), 234 units : "m", 235 maxResolution : 156543.0339, 236 maxExtent : new OpenLayers.Bounds(-20037508.3392, -20037508.3392, 237 20037508.3392, 20037508.3392), 238 controls : [ /* new OpenLayers.Control.LoadingPanel(), */ 239 new OpenLayers.Control.KeyboardDefaults(), 240 new OpenLayers.Control.Navigation({ 241 documentDrag : true, 242 dragPanOptions : { 243 interval : 1, 244 enableKinetic : true 245 } 246 }), new OpenLayers.Control.ScaleLine({ 247 geodesic : true 248 }) ], 249 numZoomLevels : 19 250 }); 251 252 /* add OSM map layers */ 253 m.addLayer(new OpenLayers.Layer.OSM("OpenStreetMap"), { 254 transitionEffect : "resize" 255 }); 256 m.addLayer(new OpenLayers.Layer.OSM("t@h", [ 257 "http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png", 258 "http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png", 259 "http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png" ]), 260 { 261 transitionEffect : "resize" 262 }); 263 m 264 .addLayer( 265 new OpenLayers.Layer.OSM( 266 "cycle map", 267 [ 268 "http://andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png", 269 "http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", 270 "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", 271 "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png" ]), 272 { 273 transitionEffect : 'resize', 274 attribution : 'Data CC-By-SA <a href="http://openstreetmap.org/" target="_blank">OpenStreetMap</a>, ' 275 + 'Tiles <a href="http://opencyclemap.org/" target="_blank">OpenCycleMap</a>' 276 + '<img src="http://opencyclemap.org/favicon.ico" heigth="16" width="16"/>' 277 }); 278 m 279 .addLayer(new OpenLayers.Layer.OSM( 280 "cloudmade map", 281 "http://tile.cloudmade.com/2f59745a6b525b4ebdb100891d5b6711/3/256/${z}/${x}/${y}.png", 282 { 283 transitionEffect : "resize" 284 })); 285 m.addLayer(new OpenLayers.Layer.OSM("hike and bike map", 286 "http://toolserver.org/tiles/hikebike/${z}/${x}/${y}.png", { 287 transitionEffect : "resize" 288 })); 289 /* add MapQuest map layers */ 290 if (mqEnable) { 291 m 292 .addLayer(new OpenLayers.Layer.OSM( 293 "MapQuest road", 294 [ 295 "http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png", 296 "http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png", 297 "http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png", 298 "http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png" ], 299 { 300 transitionEffect : "resize", 301 attribution : 'Data CC-By-SA <a href="http://openstreetmap.org/" target="_blank">OpenStreetMap</a>, ' 302 + 'Tiles <a href="http://www.mapquest.com/" target="_blank">MapQuest</a>' 303 + '<img src="http://developer.mapquest.com/content/osm/mq_logo.png" heigth="16" width="16"/>' 304 })); 305 m 306 .addLayer(new OpenLayers.Layer.OSM( 307 "MapQuest aerial", 308 [ 309 "http://oatile1.mqcdn.com/naip/${z}/${x}/${y}.jpg", 310 "http://oatile2.mqcdn.com/naip/${z}/${x}/${y}.jpg", 311 "http://oatile3.mqcdn.com/naip/${z}/${x}/${y}.jpg", 312 "http://oatile4.mqcdn.com/naip/${z}/${x}/${y}.jpg" ], 313 { 314 transitionEffect : "resize", 315 attribution : 'Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a>' 316 + '<img src="http://developer.mapquest.com/content/osm/mq_logo.png" heigth="16" width="16">' 317 })); 318 } 319 320 /* open aerial map layers */ 321 /* 322 * turn this off; project is asleep: 323 * https://sourceforge.net/tracker/?func=detail&aid=2897327&group_id=239475&atid=1110186 324 * m.addLayer(new OpenLayers.Layer.XYZ("OpenAerialMap", 325 * "http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/${z}/${x}/${y}.jpg", 326 * {name: "OpenStreetMap", attribution: "Data CC-By by <a 327 * href='http://www.openaerialmap.org/licensing/'>OpenAerialMap</a>", 328 * sphericalMercator: true, transitionEffect: "resize"} )); 329 */ 330 331 /* controle of google/yahoo/ve api's beschikbaar zijn.. */ 332 if (gEnable) { 333 try { 334 m.addLayer(new OpenLayers.Layer.Google("google relief", { 335 type : G_PHYSICAL_MAP, 336 'sphericalMercator' : true, 337 transitionEffect : "resize" 338 })); 339 m.addLayer(new OpenLayers.Layer.Google("google sat", { 340 type : G_SATELLITE_MAP, 341 'sphericalMercator' : true, 342 transitionEffect : "resize" 343 })); 344 m.addLayer(new OpenLayers.Layer.Google("google hybrid", { 345 type : G_HYBRID_MAP, 346 'sphericalMercator' : true, 347 transitionEffect : "resize" 348 })); 349 m.addLayer(new OpenLayers.Layer.Google("google normal", { 350 type : G_NORMAL_MAP, 351 'sphericalMercator' : true, 352 transitionEffect : "resize" 353 })); 354 } catch (ol_err1) { 355 } 356 } 357 358 // if (yEnable) { 359 // try { 360 // m.addLayer(new OpenLayers.Layer.Yahoo("yahoo", { 361 // 'type' : YAHOO_MAP_HYB, 362 // 'sphericalMercator' : true, 363 // transitionEffect : resize 364 // })); 365 // } catch (ol_err2) { 366 // } 367 // } 368 369 if (veEnable) { 370 try { 371 m.addLayer(new OpenLayers.Layer.VirtualEarth("ve", { 372 'type' : VEMapStyle.Hybrid, 373 'sphericalMercator' : true, 374 transitionEffect : resize 375 })); 376 } catch (ol_err3) { 377 } 378 } 379 m.setCenter(new OpenLayers.LonLat(mapOpts.lon, mapOpts.lat).transform( 380 m.displayProjection, m.projection), mapOpts.zoom); 381 extent.extend(m.getExtent()); 382 383 if (mapOpts.controls === 1) { 384 /* add base controls to map */ 385 m.addControl(new OpenLayers.Control.LayerSwitcher()); 386 m.addControl(new OpenLayers.Control.PanZoomBar()); 387 m.addControl(new OpenLayers.Control.Graticule({ 388 visible : false 389 })); 390 391 // add overlays 392 m.addLayer(new OpenLayers.Layer.OSM("Hillshade", 393 "http://toolserver.org/~cmarqu/hill/${z}/${x}/${y}.png", { 394 transitionEffect : 'resize', 395 isBaseLayer : false, 396 transparent : true, 397 visibility : false, 398 displayOutsideMaxExtent : true, 399 attribution : '' 400 })); 401 402 // TODO optioneel overzichts kaart toevoegen 403 // var overViewOpts = {layers: [wms.clone()],size: new 404 // OpenLayers.Size(120,120),projection: new 405 // OpenLayers.Projection("EPSG:900913"),opacity: 0.0,mapOptions: { 406 // /* Available resolutions are: [156543.03390000001, 407 // 78271.516950000005, 408 // 39135.758475000002, 19567.879237500001, 9783.9396187500006, 409 // 4891.9698093750003, 2445.9849046875001, 1222.9924523437501, 410 // 611.49622617187504, 305.74811308593752, 152.87405654296876, 411 // 76.43702827148438, 38.21851413574219, 19.109257067871095, 412 // 9.5546285339355475, 413 // 4.7773142669677737, 2.3886571334838869, 1.1943285667419434, 414 // 0.59716428337097172, 0.29858214168548586]*/ 415 // maxResolution: 78271.51695,maxExtent: new 416 // OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), 417 // /* 418 // minExtent: new OpenLayers.Bounds(1000,400000,400000,515000),*/ 419 // numZoomLevels: 5},'div':OpenLayers.Util.getElement('overview')}; 420 // map.addControl(new OpenLayers.Control.OverviewMap(overViewOpts)); 421 } 422 423 if (mapOpts.statusbar === 1) { 424 // statusbar control: permalink 425 m.addControl(new OpenLayers.Control.Permalink(mapOpts.id 426 + '-statusbar-link-ref')); 427 // statusbar control: mouse pos. 428 // TODO kijken naar afronding met aNumber.toFixed(0) 429 m.addControl(new OpenLayers.Control.MousePosition({ 430 'div' : OpenLayers.Util.getElement(mapOpts.id 431 + '-statusbar-mouseposition') 432 })); 433 // statusbar control: scale 434 m.addControl(new OpenLayers.Control.Scale(mapOpts.id 435 + '-statusbar-scale')); 436 // statusbar control: attribution 437 m.addControl(new OpenLayers.Control.Attribution({ 438 'div' : OpenLayers.Util.getElement(mapOpts.id + '-statusbar-text') 439 })); 440 // statusbar control: projection 441 OpenLayers.Util.getElement(mapOpts.id + '-statusbar-projection').innerHTML = m.displayProjection; 442 } else { 443 OpenLayers.Util.getElement(mapOpts.id + '-olStatusBar').display = 'none'; 444 } 445 446 if (mapOpts.toolbar === 1) { 447 // buttons + panel 448 var zoomin = new OpenLayers.Control.ZoomBox({ 449 title : "Zoom in" 450 }); 451 var zoomout = new OpenLayers.Control.ZoomBox({ 452 out : true, 453 title : "Zoom uit", 454 displayClass : "olControlZoomOut" 455 }); 456 var pan = new OpenLayers.Control.DragPan({ 457 title : "Verschuif" 458 }); 459 // icon_query.png 460 var nav = new OpenLayers.Control.NavigationHistory(); 461 m.addControl(nav); 462 var panel = new OpenLayers.Control.Panel({ 463 defaultControl : pan, 464 displayClass : "olToolbar", 465 "div" : OpenLayers.Util.getElement(mapOpts.id + "-olToolbar") 466 }); 467 panel.addControls([ zoomin, zoomout, pan, nav.next, nav.previous ]); 468 // panel.addControls([ nav.next, nav.previous ]); 469 m.addControl(panel); 470 } else { 471 OpenLayers.Util.getElement(mapOpts.id + '-olToolbar').display = 'none'; 472 } 473 474 if (OLmapPOI.length > 0) { 475 var markers = new OpenLayers.Layer.Vector( 476 "POI", 477 { 478 styleMap : new OpenLayers.StyleMap( 479 { 480 "default" : { 481 externalGraphic : "${img}", 482 graphicHeight : 16, 483 graphicWidth : 16, 484 graphicXOffset : 0, 485 graphicYOffset : -8, 486 graphicOpacity : "${opacity}", 487 rotation : "${angle}", 488 backgroundGraphic : DocBase 489 + "lib/plugins/openlayersmap/icons/marker_shadow.png", 490 backgroundXOffset : 0, 491 backgroundYOffset : -4, 492 backgroundRotation : "${angle}", 493 pointRadius : 10, 494 labelXOffset : 8, 495 labelYOffset : 8, 496 labelAlign : "lb", 497 label : "${label}", 498 // fontColor : "", 499 fontFamily : "monospace", 500 fontSize : "12px", 501 fontWeight : "bold" 502 }, 503 "select" : { 504 cursor : "crosshair", 505 externalGraphic : DocBase 506 + "lib/plugins/openlayersmap/icons/marker-red.png", 507 graphicHeight : 16, 508 graphicWidth : 16, 509 graphicXOffset : 0, 510 graphicYOffset : -8, 511 graphicOpacity : 1.0, 512 rotation : "${angle}" 513 } 514 }), 515 isBaseLayer : false, 516 rendererOptions : { 517 yOrdering : true 518 } 519 }); 520 521 m.addLayer(markers); 522 var features = []; 523 var lonLat; 524 for ( var j = 0; j < OLmapPOI.length; j++) { 525 var feat = new OpenLayers.Feature.Vector( 526 new OpenLayers.Geometry.Point(OLmapPOI[j].lon, 527 OLmapPOI[j].lat).transform(m.displayProjection, 528 m.projection), { 529 angle : OLmapPOI[j].angle, 530 opacity : OLmapPOI[j].opacity, 531 img : DocBase + "lib/plugins/openlayersmap/icons/" 532 + OLmapPOI[j].img, 533 label : OLmapPOI[j].rowId 534 }); 535 feat.data = { 536 name : OLmapPOI[j].txt, 537 rowId : OLmapPOI[j].rowId 538 }; 539 features.push(feat); 540 } 541 markers.addFeatures(features); 542 extent.extend(markers.getDataExtent()); 543 m.zoomToExtent(extent); 544 } 545 546 /* GPX layer */ 547 if (mapOpts.gpxfile.length > 0) { 548 var layerGPX = new OpenLayers.Layer.GML("GPS route", DocBase 549 + "lib/exe/fetch.php?media=" + mapOpts.gpxfile, { 550 format : OpenLayers.Format.GPX, 551 formatOptions : { 552 extractWaypoints : true, 553 extractTracks : true, 554 extractStyles : true, 555 extractAttributes : true, 556 handleHeight : true, 557 maxDepth : 3 558 }, 559 style : { 560 strokeColor : "#0000FF", 561 strokeWidth : 3, 562 strokeOpacity : 0.7, 563 pointRadius : 4, 564 fillColor : "#0099FF", 565 fillOpacity : 0.7 566 /* 567 * , label:"${name}" 568 */}, 569 projection : new OpenLayers.Projection("EPSG:4326") 570 }); 571 m.addLayer(layerGPX); 572 layerGPX.events.register('loadend', m, function() { 573 extent.extend(layerGPX.getDataExtent()); 574 m.zoomToExtent(extent); 575 }); 576 577 } 578 579 /* KML layer */ 580 if (mapOpts.kmlfile.length > 0) { 581 var layerKML = new OpenLayers.Layer.GML("KML file", DocBase 582 + "lib/exe/fetch.php?media=" + mapOpts.kmlfile, { 583 format : OpenLayers.Format.KML, 584 formatOptions : { 585 extractStyles : true, 586 extractAttributes : true, 587 maxDepth : 3 588 }, 589 style : { 590 label : "${name}" 591 }, 592 projection : new OpenLayers.Projection("EPSG:4326") 593 }); 594 m.addLayer(layerKML); 595 layerKML.events.register('loadend', m, function() { 596 extent.extend(layerKML.getDataExtent()); 597 m.zoomToExtent(extent); 598 }); 599 } 600 601 // selectcontrol for layers 602 if ((m.getLayersByClass('OpenLayers.Layer.GML').length > 0) 603 || m.getLayersByClass('OpenLayers.Layer.Vector').length > 0) { 604 selectControl = new OpenLayers.Control.SelectFeature((m 605 .getLayersByClass('OpenLayers.Layer.Vector')).concat(m 606 .getLayersByClass('OpenLayers.Layer.GML')), { 607 multiple : true, 608 hover : mapOpts.poihoverstyle, 609 onSelect : onFeatureSelect, 610 onUnselect : onFeatureUnselect 611 }); 612 m.addControl(selectControl); 613 selectControl.activate(); 614 } 615 616 // change/set alternative baselyr 617 try { 618 m.setBaseLayer(m.getLayersByName(mapOpts.baselyr)[0]); 619 } catch (ol_err4) { 620 m.setBaseLayer(m.layers[0]); 621 } 622 return m; 623} 624 625/** 626 * ol api flag. 627 * 628 * @type {Boolean} 629 */ 630var olEnable = false, 631/** 632 * MapQuest tiles flag. 633 * 634 * @type {Boolean} 635 */ 636mqEnable = false, 637/** 638 * google map api flag. 639 * 640 * @type {Boolean} 641 */ 642gEnable = false, 643/** 644 * virtual earth map api flag. 645 * 646 * @type {Boolean} 647 */ 648veEnable = false; 649/** 650 * yahoo map api flag. 651 * 652 * @type {Boolean} 653 */ 654// yEnable = false; 655/* register olInit to run with onload event. */ 656addInitEvent(olInit); 657