0

I want to create a highlight control which will highlight a line, it should highlight the line when the cursor is near this line (e.g. ~10px) and when cursor is pointing to line. I have following code, but it only works if I put cursor directly on drawn line.

highlightCtrl = new OpenLayers.Control.SelectFeature([routesLayer], {
            hover: true,
            highlightOnly: true,
            eventListeners: {
                featurehighlighted: HighLightRoute,
                featureunhighlighted: unHighLightRoute
            }
        });
1

My solution:

  • Add new layer that will draw the same vector line, features should have higher strokeWidth than original layer, strokeOpacityshould be equal to zero (becauseit should be invisible for user)
  • Add this new invisible layer to highlightCtrl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.