Changeset 12204 for extensions/GMaps/js/gmapsMarkup.js
- Timestamp:
- Sep 23, 2011, 10:44:08 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GMaps/js/gmapsMarkup.js
r10551 r12204 2 2 * ----------------------------------------------------------------------------- 3 3 * file: gmapsMarkup.js 4 * file version: 1.1. 15 * date: 2011-0 4-134 * file version: 1.1.2 5 * date: 2011-09-23 6 6 */ 7 7 8 var markerImgProp = [ 8 9 var gmapsCM=null, 10 gmapsMM=null; 11 12 function markupMaps() 13 { 14 var markerImgProp = [ 9 15 null, 10 16 { w:32, h:32, x:15, y:31 }, // s01 … … 14 20 ]; 15 21 16 17 function markupMaps()18 {19 22 /** 20 23 * create the map … … 94 97 if(properties.fitToBounds) 95 98 { 96 fitToBounds(map.bounds, gmapsIndex);99 this.fitToBounds(map.bounds, gmapsIndex); 97 100 } 98 101 else … … 104 107 if(properties.markerVisible) 105 108 { 106 loadMarkers(map);109 this.loadMarkers(map); 107 110 } 108 111 else 109 112 { 110 initializeMapViewport(gmapsIndex);113 this.initializeMapViewport(gmapsIndex); 111 114 } 112 115 }; … … 117 120 * @param Map map : the map 118 121 */ 119 var loadMarkers = function(map) 120 { 122 this.loadMarkers = function(map) 123 { 124 var __this=this; 125 121 126 if(map.getBounds()==null) return(false); 122 127 map.callId++; … … 150 155 { 151 156 tmp.markers.sort(compareMarkers); 152 applyMarkers(gmapsMarkup.maps[tmp.loadIndex].gMap, tmp.markers);153 initializeMapViewport(tmp.loadIndex);157 __this.applyMarkers(gmapsMarkup.maps[tmp.loadIndex].gMap, tmp.markers); 158 __this.initializeMapViewport(tmp.loadIndex); 154 159 } 155 160 } … … 166 171 * latitude, longitude, nbImg 167 172 */ 168 varapplyMarkers = function(map, markers)173 this.applyMarkers = function(map, markers) 169 174 { 170 175 if(map==null) return(false); … … 178 183 while(i<map.markers.length) 179 184 { 180 newListIndex= markerInList(map.markers[i].uId, markers);185 newListIndex=this.markerInList(map.markers[i].uId, markers); 181 186 if(newListIndex==-1) 182 187 { … … 197 202 for(var i=0;i<markers.length;i++) 198 203 { 199 var marker = new google.maps.Marker( 200 { 201 position:new google.maps.LatLng(markers[i].lat, markers[i].lng), 202 map: map, 203 title:markers[i].nbImgTxt 204 } 205 ); 204 var __this=this, 205 marker = new google.maps.Marker( 206 { 207 position:new google.maps.LatLng(markers[i].lat, markers[i].lng), 208 map: map, 209 title:markers[i].nbImgTxt 210 } 211 ); 206 212 207 213 if(map.markerImg!=null) marker.setIcon(map.markerImg); … … 224 230 function () 225 231 { 226 displayWindowInfo(this);232 __this.displayWindowInfo(this); 227 233 } 228 234 ); … … 257 263 }; 258 264 259 varmarkerInList=function(uniqueId, markerList)265 this.markerInList=function(uniqueId, markerList) 260 266 { 261 267 for(var i=0;i<markerList.length;i++) … … 271 277 * @param Marker marker : the marker 272 278 */ 273 var displayWindowInfo=function(marker) 274 { 279 this.displayWindowInfo=function(marker) 280 { 281 if(gmapsCM && gmapsCM instanceof categoryMaps) gmapsCM.closePictureInfo(); 282 275 283 gmapsMarkup.currentInfo=marker.info; 276 284 gmapsMarkup.infoWindow.close(); 277 285 gmapsMarkup.infoWindow.setContent($('#iGMapsInfoWindowContent').clone().each(renameId).get(0)); 278 286 gmapsMarkup.infoWindow.open(marker.map, marker); 279 displayPictureInfo(gmapsMarkup.currentInfo.displayed); 287 $('#ciWALeft, #ciWARight').unbind('click'); 288 $('#ciWARight').bind('click', function(event) { __this.displayPictureNext(); } ); 289 $('#ciWALeft').bind('click', function(event) { __this.displayPicturePrev(); } ); 290 this.displayPictureInfo(gmapsMarkup.currentInfo.displayed); 280 291 }; 281 292 var renameId=function(i, e) … … 286 297 287 298 288 /** 289 * 290 */ 291 var displayPictureInfo=function(index) 292 { 299 this.closePictureInfo = function () 300 { 301 gmapsMarkup.currentInfo=null; 302 gmapsMarkup.infoWindow.setContent(''); 303 gmapsMarkup.infoWindow.close(); 304 $('#ciWALeft, #ciWARight').unbind('click'); 305 } 306 307 /** 308 * 309 */ 310 this.displayPictureInfo=function(index) 311 { 312 var __this=this; 313 314 $('#ciWALeft,#ciWARight').unbind('click'); 315 $('#ciWARight').bind('click', 316 function(event) 317 { 318 __this.displayPictureNext(); 319 } 320 ); 321 $('#ciWALeft').bind('click', 322 function(event) 323 { 324 __this.displayPicturePrev(); 325 } 326 ); 327 293 328 gmapsMarkup.currentInfo.displayed=index; 294 329 if(gmapsMarkup.currentInfo.imgName[index]=='') … … 344 379 gmapsMarkup.currentInfo.displayed--; 345 380 if(gmapsMarkup.currentInfo.displayed<0) gmapsMarkup.currentInfo.displayed=gmapsMarkup.currentInfo.nbImg-1; 346 displayPictureInfo(gmapsMarkup.currentInfo.displayed);381 this.displayPictureInfo(gmapsMarkup.currentInfo.displayed); 347 382 }; 348 383 … … 354 389 gmapsMarkup.currentInfo.displayed++; 355 390 if(gmapsMarkup.currentInfo.displayed>=gmapsMarkup.currentInfo.nbImg) gmapsMarkup.currentInfo.displayed=0; 356 displayPictureInfo(gmapsMarkup.currentInfo.displayed);391 this.displayPictureInfo(gmapsMarkup.currentInfo.displayed); 357 392 }; 358 393 … … 361 396 * check if zoomLevel 362 397 */ 363 varfitToBounds=function(bounds, mapIndex)398 this.fitToBounds=function(bounds, mapIndex) 364 399 { 365 400 gmapsMarkup.maps[mapIndex].gMap.fitBounds(bounds); … … 372 407 }; 373 408 374 var initializeMapViewport=function(mapIndex) 375 { 409 this.initializeMapViewport=function(mapIndex) 410 { 411 var __this=this; 412 376 413 if(mapIndex>-1 && !gmapsMarkup.maps[mapIndex].gMap.initialized) 377 414 { … … 386 423 function() 387 424 { 388 loadMarkers(this);425 __this.loadMarkers(this); 389 426 } 390 427 ); … … 395 432 function() 396 433 { 397 loadMarkers(this);434 __this.loadMarkers(this); 398 435 gmapsMarkup.infoWindow.close(); 399 436 } … … 409 446 function() 410 447 { 411 fitToBounds(gmapsMarkup.maps[mapIndex].gMap.kmlFile.getDefaultViewport(), mapIndex);448 __this.fitToBounds(gmapsMarkup.maps[mapIndex].gMap.kmlFile.getDefaultViewport(), mapIndex); 412 449 } 413 450 ); … … 422 459 423 460 424 $(window).load(function () 425 { 426 var mm=new markupMaps(); 461 $(window).load( 462 function () 463 { 464 gmapsMM=new markupMaps(); 427 465 428 466 // all maps have the same initials bounds … … 434 472 'closeclick', 435 473 function () { 436 //$('body').append($('#iGMapsInfoWindowContent'));437 474 gmapsMarkup.infoWindow.setContent(''); 438 475 $('#ciGMIWC_img').unbind(); … … 465 502 ); 466 503 467 mm.createMap(gmapsMarkup.maps[i], i);504 gmapsMM.createMap(gmapsMarkup.maps[i], i); 468 505 } 469 506 } 470 507 } 471 508 ); 472 473 474 if($('#iGMapsInfoWindow').length==0)475 {476 $('body').append($('<div/>',477 {478 id:'iGMapsInfoWindow',479 css:{display:'none'},480 }481 ).append($('<div/>',482 {483 id:'iGMapsInfoWindowContent'484 }485 ).append($('<div/>',486 {487 id:'iGMIWC_title',488 html:'(title)'489 }490 )491 ).append($('<table/>',492 {493 id:'iGMIWC_thumb'494 }495 ).append($('<tr/>')496 .append($('<td/>',497 {498 css:{width:'28px'}499 }500 ).append($('<div id="iWALeft" onclick="mm.displayPicturePrev();"/>')501 )502 )503 .append($('<td/>').append($('<img/>',504 {505 id:'iGMIWC_img',506 src:''507 }508 )509 )510 )511 .append($('<td/>',512 {513 css:{width:'28px'}514 }515 ).append($('<div id="iWARight" onclick="mm.displayPictureNext();">')516 )517 )518 )519 )520 .append($('<div/>',521 {522 id:'iGMIWC_picnum',523 html:'0/0 photo'524 }525 )526 )527 .append($('<div/>',528 {529 id:'iGMIWC_showcat',530 css:{display:'none'}531 }532 ).append($('<span/>',533 {534 html:'gmaps_i_show_this_picture_in'535 }536 )537 )538 .append($('<ul/>',539 {540 id:'iGMIWC_showcatList'541 }542 )543 )544 )545 )546 );547 }548 549 509 } 550 510 );
Note: See TracChangeset
for help on using the changeset viewer.