"source" is not listed as a property of ol.Overlay http://openlayers.org/en/latest/apidoc/ol.Overlay.html
The developers prefer that questions are posted on stackoverflow https://stackoverflow.com/questions/tagged/openlayers rather than this list. Rich On Thu, Jan 18, 2018 at 10:03 AM, < openlayers-dev+apn2wqf6ypag5jfpvlegbdfcja2m6vzgriypktb35_uqxq...@googlegroups.com > wrote: > I have defined my own featureOverlay for the purposes of highlighting any > polygon layer I hover over. When I try to make this work with > featureOverlay.getSource(), I get the error featureOverlay.getSource() is > not a function. Below is the code where I define my feature Overlay, as > well as the functionality for adding the featureOverlay(which is > essentially a new Overlay with designated highlight details. > > const featureOverlay = new Overlay({ > source: new VectorSource(), > zIndex: 0, > map: map, > style: new ol.style.Style({ > stroke: new ol.style.Stroke({ > color: [155, 155, 0], > width: 3.5 > }), > fill: new ol.style.Fill({ > color: 'rgba(0, 0, 0, 0.8)' > }) > }) > }); > > map.on('pointermove', function(e){ > > > > if (cursorSet) return; > if (e.dragging) return; > var pixel = map.getEventPixel(e.originalEvent); > var hit = map.hasFeatureAtPixel(pixel); > // console.log("Place break point here") > if(hit) { > var feature = map.forEachFeatureAtPixel(e.pixel,function(feature) > { > if (clicked && feature) { > e.map.getTargetElement().style.cursor = hit ? > 'pointer' : ''; > cursorSet = true; > return; > console.log("clicked and Feature"); > } > featureToRemove = feature; > if (!clicked && feature !== highlight) { > if (highlight) { > featureOverlay.getSource(). > removeFeature(highlight); > } > if (!clicked && feature) { > featureOverlay.getSource(). > addFeature(feature); > } > console.log("Hit me man") > highlight = feature; > } > > }); > } else { > console.log("do something ELSE") > } > }); > > -- > You received this message because you are subscribed to the Google Groups > "OpenLayers Dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/openlayers-dev. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/openlayers-dev/463fbd76-9b5c-490d-a221-cf1796de6783% > 40googlegroups.com > <https://groups.google.com/d/msgid/openlayers-dev/463fbd76-9b5c-490d-a221-cf1796de6783%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Richard W. Greenwood, PLS www.greenwoodmap.com -- You received this message because you are subscribed to the Google Groups "OpenLayers Dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/openlayers-dev. To view this discussion on the web visit https://groups.google.com/d/msgid/openlayers-dev/CAHBySPZcKWXJGaYAnJEtkBsrBQ1oJw8BiPKEHRMC-m2HEFfpjg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
