in Education by
It sounds so simple but I can't find any newbie tutorial: Could anybody give me a simple example how I create (vektor)markers in OpenLayers that open an infowindow on mouseover and even close it on mouseout? I found parts of this explained but not all of it.... JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
For a simple example of how to do this, you need to do a couple of things: Create a vector layer to contain your markers and add it to the map: this.markerLayer = new OpenLayers.Layer.Vector( "My Marker Layer", { /* configuration options are set here */ } ); map.addLayer(this.markerLayer); Create your marker and add it to the map: var marker = new OpenLayers.Feature.Vector(point, attributes, markerStyle); this.markerLayer.addFeatures([marker]); Create a select control for your layer, and register a function to build your popup when the user hovers over your marker: var selectControl = new OpenLayers.Control.SelectFeature(this.markerLayer, { hover: true }); selectControl.events.register('featurehighlighted', null, onFeatureHighlighted); Build your popup: onFeatureHighlighted: function (evt) { // Needed only for interaction, not for the display. var onPopupClose = function (evt) { // 'this' is the popup. var feature = this.feature; if (feature.layer) { selectControl.unselect(feature); } this.destroy(); } feature = evt.feature; popup = new OpenLayers.Popup.FramedCloud("featurePopup", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(100,100), "

"+feature.attributes.station_na + "

" + "Location: " + feature.attributes.location + '
' + "Elevation: " + feature.attributes.elev_, null, true, onPopupClose); feature.popup = popup; popup.feature = feature; map.addPopup(popup, true); }, // ...

Related questions

0 votes
    I have a polygon feature in OpenLayers 5. It has some random id which I need to show at the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    When is the mouseover event fired? (a) When mouse is moved over a new element (b) When mouse is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    I'm using flutter_map package and I need to draw path between 2 marker. I know map_view package provided ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    See the picture below. In my application (with MapView) usage, I would like to use such default markers ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    What are the components of a marker interface? (a) Fields and methods (b) No fields, only methods (c) Fields, no ... JSP & API of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    Which of the following is not a marker interface? (a) Serializable (b) Cloneable (c) Remote (d) Reader This ... JSP & API of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    What are the components of a marker interface? (a) Fields and methods (b) No fields, only methods ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    Which of the following is not a marker interface? (a) Serializable (b) Cloneable (c) Remote (d) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    What are the uses of Marker interface?...
asked Dec 21, 2020 in Technology by JackTerrance
0 votes
    What is marker interface in JAVA?...
asked Dec 21, 2020 in Technology by JackTerrance
0 votes
    I'm new to flutter and can't resolve the issue. Your application could not be compiled, because its ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I'm new to flutter and can't resolve the issue. Your application could not be compiled, because its ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    ________ is a simple approach to supervised learning. It assumes that the dependence of Y on X1, X2, . ... Regression of R Programming Select the correct answer from above options...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    SELECT TOP (1) Ordreliste.OrdreID, Ordreliste.KundeID, Ordreliste.OrdreDato, Ordreliste.Navn, Ordreliste.Farve FROM ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 7, 2022 in Education by JackTerrance
0 votes
    SELECT TOP (1) Ordreliste.OrdreID, Ordreliste.KundeID, Ordreliste.OrdreDato, Ordreliste.Navn, Ordreliste.Farve FROM ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 5, 2022 in Education by JackTerrance
...