Tuesday, 6 September 2016

javascript - Openlayers How would i get a hover label over my polygon


make a hover/mouseover label for a polygon in Openlayers?


I made a map with draw, delete and drag polygon function.


Now I need to make a hover mouseover for this.


How to get a hover label for polygon


        var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");

map.addLayers([wmsLayer, polygonLayer]);


polyOptions = {sides: 40};
polygonControl = new OpenLayers.Control.DrawFeature(polygonLayer,
OpenLayers.Handler.RegularPolygon,
{handlerOptions: polyOptions} );

var myStyles = new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
pointRadius: "${type}", // sized according to type attribute
fillColor: "#ffcc66",

strokeColor: "#ff9933",
strokeWidth: 2,
graphicZIndex: 1
}),
"select": new OpenLayers.Style({
fillColor: "#66ccff",
strokeColor: "#3399ff",
graphicZIndex: 2
})
});


var select = new OpenLayers.Control.SelectFeature(polygonLayer, {hover: true});
map.addControl(select);
select.activate();

Answer



Edit: 5/13/2015. Updating links. Thank you @Dennis-van-Schaik


Hover


http://dev.openlayers.org/examples/highlight-feature.html


Popup


http://dev.openlayers.org/examples/popupMatrix.html



http://dev.openlayers.org/examples/sundials.html


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...