1var riotSolrMapMarker = function(data) { 2 this.latlng = data.position; 3 this.pt = data.position; 4 this.position = data.position; 5 // Set our RiotSolrItem instance 6 this.item = data.item; 7 // Make the tag options accessible 8 this.opts = data.opts; 9 // Add the type of riot tag and indexId. These get added as CSS classes. 10 // This allows more styling possibilities. 11 this.tagType = data.tagType; 12 this.indexId = data.indexId; 13 // Once the LatLng and text are set, add the overlay to the map. This will 14 // trigger a call to panes_changed which should in turn call draw. 15 this.setMap(data.map); 16}; 17 18/** 19 * Have our marker prototype "extend" OverlayView 20 * @type {google.maps.OverlayView} 21 */ 22riotSolrMapMarker.prototype = new google.maps.OverlayView(); 23 24/** 25 * Draw the overlay. 26 */ 27riotSolrMapMarker.prototype.draw = function() { 28 var self = this, div = this.div; 29 // Check if the div has been created. 30 if (!div && this.map) { 31 // Create the DIV representing our riotSolrMapMarker 32 div = this.div = document.createElement('DIV'); 33 // Add some classes to allow theme'rs to override the styles. 34 this.getMarkerClasses() 35 .forEach(function(value, key) { 36 div.classList.add(value) 37 }); 38 // Note what you don't see here. Any styles. It's all in the SCSS. 39 // Use the classes you see above and go to town. 40 41 // Proxy events on the overlay instance. 42 //Click 43 google.maps.event.addDomListener(div, "click", function(event) { 44 google.maps.event.trigger(self, "click"); 45 // Without this line; overlays which overlap POIs 46 // will have their click events bubble up to the map 47 // canvas and end up triggering the info window for the POI. 48 event.stopPropagation(); 49 }); 50 51 // Mouse enter 52 google.maps.event.addDomListener(div, "mouseover", function(event) { 53 self.div.classList.add('focused'); 54 google.maps.event.trigger(self, "mouseover"); 55 }); 56 57 // Mouse leave 58 google.maps.event.addDomListener(div, "mouseleave", function(event) { 59 self.div.classList.remove('focused'); 60 google.maps.event.trigger(self, "mouseleave"); 61 }); 62 63 //@todo: more as we need them. 64 65 // Then add the overlay to the DOM 66 var panes = this.getPanes(); 67 panes.overlayImage.appendChild(div); 68 } 69 70 // Position the overlay 71 var point = this.getProjection().fromLatLngToDivPixel(this.latlng); 72 if (point && div) { 73 div.style.left = (point.x - 8) + 'px'; 74 div.style.top = (point.y - 8) + 'px'; 75 } 76}; 77 78/** 79 * Check if the overlay was on the map and needs to be removed.= 80 */ 81riotSolrMapMarker.prototype.remove = function() { 82 if (this.div) { 83 this.div.parentNode.removeChild(this.div); 84 this.div = null; 85 } 86}; 87 88/** 89 * Get the current position of the overlay 90 * @returns {*} 91 */ 92riotSolrMapMarker.prototype.getPosition = function() { 93 return this.latlng; 94}; 95 96/** 97 * A list of CSS classes to add. 98 * @returns {[string,*,*,*]} 99 */ 100riotSolrMapMarker.prototype.getMarkerClasses = function(){ 101 var classes = [ 102 'riot-solr-map-marker', 103 this.tagType, 104 this.indexId, 105 'item-' + this.item.item_id 106 ], self = this, items; 107 108 if(!this.opts.marker_css_classes) { 109 return classes; 110 } 111 112 items = this.opts.marker_css_classes.split(','); 113 114 // Private process function for parsing the configuration 115 var process = function(value) { 116 // a property of the item just add it as a class. 117 if(!self.item[value]) { 118 classes.push(value) 119 } 120 else { 121 Array.isArray(self.item[value]) 122 ? classes.push(self.item[value][0]) 123 : classes.push(self.item[value]); 124 } 125 }; 126 127 if(Array.isArray(items)) { 128 items.forEach(function(value, key) { 129 process(value) 130 }); 131 } 132 else { 133 process(items) 134 } 135 136 return classes; 137}; 138 139riotSolrMapMarker.prototype.getVisible = function() { 140 return this.getVisible; 141} 142 143riotSolrMapMarker.prototype.getZIndex = function() { 144 return this.getZIndex; 145} 146 147riotSolrMapMarker.prototype.setZIndex = function() { 148 return this.setZIndex; 149} 150 151riotSolrMapMarker.prototype.setPosition = function(pos) { 152 return this.latlng = pos; 153}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.