Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Any suggestions on how to show a point on mouse over a hidden polygon?

A single kml file contains two polygons and two points as in the image, I've hidden these polygon and point by setting stylemap fill color, is there any way to show the points on mouse over the hidden polygon.

Any guidance and help is appreciated.

kml layer

Thanks in advance.

share|improve this question
    
@underdark: thanks for the edit –  bios Aug 22 '12 at 14:46

1 Answer 1

up vote 3 down vote accepted

One way is to trigger styled render intent using OpenLayers.Control.SelectFeature

Here is a demo which allows the line vertices (points) to become visible on hover.

UPDATE:

The key is to define a stylemap with two render intents, a default one, and another one for the hover style. Then set event listeners on the highlight control which will listen for the polygon, but trigger the highlight/unhighlight of the point.

HERE is a new DEMO that accomplishes what you want to do.

enter image description here

var polygonLayer = new OpenLayers.Layer.Vector("Polygons", {
    styleMap: new OpenLayers.StyleMap({
        "default": new OpenLayers.Style({
            strokeColor: 'Transparent', // change this to strokeColor: '#0000cc', to see the polygons
            fillColor: 'Transparent'
        }),
        "temporary": new OpenLayers.Style({
            strokeColor: 'Transparent', // change this to strokeColor: '#0000cc', to see the polygons
            fillColor: 'Transparent'
        })
    })
});

var pointLayer = new OpenLayers.Layer.Vector("Points", {
    styleMap: new OpenLayers.StyleMap({
        "default": new OpenLayers.Style({
            strokeColor: 'Transparent',
            fillColor: 'Transparent',
            pointRadius: 6
        }),
        "temporary": new OpenLayers.Style({
            strokeColor: '#0000cc',
            fillColor: '#0000cc',
            strokeOpacity: .8,
            strokeWidth: 1,
            fillOpacity: .3,
            cursor: "default",
            pointRadius: 6
        })
    })
});
share|improve this answer
    
I'm hiding both point and polygon and trying to display the point when mouse enter into the hidden polygon. Is it possible? –  bios Aug 22 '12 at 3:48
    
Absolutely... I misunderstood your question. I'm going to re-write my answer. –  CaptDragon Aug 22 '12 at 13:58
    
@bios please see update. –  CaptDragon Aug 22 '12 at 14:06
    
thanks for the update –  bios Aug 22 '12 at 14:45
1  
No problem, Don't forget to upvote ;). –  CaptDragon Aug 22 '12 at 14:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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