Changeset 33186 for main/trunk
- Timestamp:
- 2019-06-21T22:26:57+12:00 (5 years ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/map-scripts-shapes-util.js
r33169 r33186 580 580 } 581 581 582 583 ShapesUtil.setOpacity = function (shape, opacity) { 584 if (shape.type === google.maps.drawing.OverlayType.RECTANGLE 585 || shape.type === google.maps.drawing.OverlayType.POLYGON 586 || shape.type === google.maps.drawing.OverlayType.CIRCLE) 587 { 588 shape.fillOpacity = opacity; 589 } else if (shape.type === google.maps.drawing.OverlayType.POLYLINE) { 590 shape.strokeOpacity = opacity; 591 } 592 else { 593 console.log("Can't set opacity on unrecognised shape: " + shape.type); 594 } 595 } -
main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js
r33185 r33186 18 18 var _scrollThroughDefault = true; // TODO: default starts at true 19 19 20 var LOW_OPACITY = 0.1; // make surrounding docs' opacity 10% 21 20 22 function initializeMapScripts() 21 23 { … … 34 36 { 35 37 _docList[jsonNodes[i].nodeID] = jsonNodes[i]; 36 _docList.ids.push(jsonNodes[i].nodeID); 37 createMarkers(jsonNodes[i], true); 38 } 38 _docList.ids.push(jsonNodes[i].nodeID); 39 var options = { 40 "mainDoc": true 41 }; 42 console.log("#### " + jsonNodes[i].nodeID + " is a main doc: "); 43 console.log(jsonNodes[i]); 44 createMarkers(jsonNodes[i], options); 45 } 46 39 47 updateMap(); 40 48 } … … 262 270 { 263 271 //console.log("*** responseText (first 250) = " + responseText.substring(0,256)); 272 273 // The first time, docList.ids contains ONLY the main/visible doc's ID and its subsections' IDs. 274 // Any one of these will do to determine 275 if(_docList.ids.length > 0) { 276 var mainDocID = _docList.ids[0]; 277 var endIndex = mainDocID.indexOf('.'); 278 if(endIndex == -1) { endIndex = mainDocID.length; } 279 mainDocID = mainDocID.substring(0, endIndex); 280 } 264 281 265 282 if(responseText.search("id=\"jsonNodes") != -1) … … 279 296 280 297 var found = false; 281 for(var j = 0; j < _docList.ids.length; j++){if(doc.nodeID == _docList.ids[j]){found = true; break;}} 298 for(var j = 0; j < _docList.ids.length; j++) { 299 if(doc.nodeID == _docList.ids[j]) { 300 found = true; 301 console.log("Found nearby ID " + doc.nodeID + " was already drawn:"); 302 console.log(jsonNodes[i]); 303 break; 304 } 305 } 282 306 283 307 if(!found) … … 286 310 _docList.ids.push(doc.nodeID); 287 311 288 createMarkers(doc, false); 312 // Some "nearby docs" are actually subsections of the main document, which are retrieved 313 // as a nearby doc by performSearchForMarkers() BEFORE the subsection is ever expanded. 314 // We need to distinguish between subsections of the main doc -- which should be displayed 315 // in their specified opacity -- and other docs and their subsections which should be displayed 316 // faded out. 317 if(typeof(mainDocID) !== 'undefined' && doc.nodeID.includes(mainDocID)) { 318 createMarkers(doc, {"mainDoc": true}); 319 } else { 320 createMarkers(doc, {"mainDoc": false}); 321 } 289 322 } 323 290 324 } 291 325 } … … 548 582 } 549 583 550 function createMarkers(doc, mainMarker) {584 function createMarkers(doc, options) { 551 585 if(doc.mapoverlay) { 552 586 //console.log("Have shapes: " + doc.mapoverlay.toString()); 553 createShapes(doc, mainMarker);587 createShapes(doc, options); 554 588 } else { // backwards compatible to deal with Lat and Lng meta stored for doc 555 589 pos = new google.maps.LatLng(doc.lat,doc.lng); 556 createMarker(doc, pos, mainMarker);590 createMarker(doc, pos, options); 557 591 } 558 592 } … … 604 638 // This function will create Google Shapes/Overlays and markers out of a given doc JSONNode's doc.mapOverlay 605 639 // (doc.mapOverlay shapes are stored as an array of JSON) and store the shapes/overlays in the doc.shapes array. 606 // Param mainMarker: if set to true, marker is red. If false, marker is blue 607 function createShapes(doc, mainMarker) 640 function createShapes(doc, options) 608 641 { 642 var isMainDoc = options["mainDoc"]; 643 609 644 // for doc.shapes: don't store JSON anymore, convert them to google Shapes overlays and store them instead 610 645 doc.shapes = []; … … 624 659 if(shape.type === google.maps.drawing.OverlayType.MARKER) { 625 660 var marker = shape; 626 // ma inMarkers should be red627 if(! mainMarker) {661 // markers of the main document should be red, else they'll be blue 662 if(!isMainDoc) { 628 663 marker["icon"] = "interfaces/" + gs.xsltParams.interface_name + "/images/bluemarker.png"; 629 664 } … … 638 673 } else { 639 674 //console.log("Creating non-marker shape."); 675 676 if(!isMainDoc) { 677 ShapesUtil.setOpacity(shape, LOW_OPACITY); 678 } // else the shape will be drawn at its configured opacity 640 679 } 641 680 … … 643 682 shape.draggable = false; 644 683 645 console.log("#### calling addInfoMarker");684 646 685 // doc[i]'s label = doc.shapes[i].description 647 686 addInfoMarker(doc, shape); … … 669 708 // This method is only for backwards compatibility: for those collections with docs that only have Lat and Lng meta 670 709 // and no GPS.mapOverlay (and hence Coordinate) meta. 671 // Param mainMarker: if set to true, marker is red. If false, marker is blue 672 function createMarker(doc, pos, mainMarker) 673 { 710 function createMarker(doc, pos, options) 711 { 712 var isMainMarker = options["mainDoc"]; 713 674 714 var marker; 675 if( mainMarker)715 if(isMainMarker) 676 716 { 677 717 marker = new google.maps.Marker … … 750 790 _docList[doc.nodeID] = doc; 751 791 _docList.ids.push(doc.nodeID); 752 753 createMarkers(doc, true); 792 793 var options = { 794 "mainDoc": true // TODO: should this be true or false??? 795 }; 796 createMarkers(doc, options); 754 797 } 755 798
Note:
See TracChangeset
for help on using the changeset viewer.