Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6577911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:42:03+00:00 2026-05-25T15:42:03+00:00

In a previous version of my program I used markers to mark points on

  • 0

In a previous version of my program I used markers to mark points on the map. In the current version I had to change from markers to vectors, because I need the extra flexibility. In the markers solution I used the function below to add a popup-box to a marker:

function createPopupBoxFeature(vector, lonLat, description) {
    var feature = new OpenLayers.Feature(vector, lonLat);

    feature.closeBox = true;
    feature.popupClass = OpenLayers.Class(OpenLayers.Popup.AnchoredBubble, 
        { "autoSize": true });
    feature.data.popupContentHTML = description;

    vector.events.register("mousedown", feature, function(evt) {
        if (this.popup == null) {
            this.popup = this.createPopup(this.closeBox);
            map.addPopup(this.popup);
            this.popup.show();
        } else {
            this.popup.toggle();
        }
        OpenLayers.Event.stop(evt);
    });

    return feature;
}

But it is no longer working for vectors, because they have no events property. How do I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:42:04+00:00Added an answer on May 25, 2026 at 3:42 pm

    Solved by myself. Here is how:

    // Used to display the dialog popup
    var selectControl;
    var selectedFeature;
    

    Add a SelectFeature

        selectControl = new OpenLayers.Control.SelectFeature(vectorLayer,
        {
            onSelect: onFeatureSelect,
            onUnselect: onFeatureUnselect 
        });
        map.addControl(selectControl);
        selectControl.activate();
    

    Event handlers

    function onPopupClose(evt) {
        selectControl.unselect(selectedFeature);
    }
    function onPopupFeatureSelect(feature) {
        selectedFeature = feature;
        popup = new OpenLayers.Popup.FramedCloud("chicken",
            feature.geometry.getBounds().getCenterLonLat(),
            null, feature.name, null, true, onPopupClose);
        popup.panMapIfOutOfView = true;
        popup.autoSize = true;
        feature.popup = popup;
        map.addPopup(popup);
    }
    function onPopupFeatureUnselect(feature) {
        map.removePopup(feature.popup);
        feature.popup.destroy();
        feature.popup = null;
    }
    

    Store the content of the popup in the vector’s name. There may be a better solution, but I don’t care. Adding popups to vectors is already difficult enough.

    vector.name = "Your popup content";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We had a command which used to work with previous version of wireshark (1)
This should be simple, I need to stop any previous version of my program
RESOLVED From the developer: the problem was that a previous version of the code
I sometimes check out some previous version of the code to examine or test.
How can I get the previous version of data of a Row in a
I want to know whether it is possible to commit to a previous version.
How can I remove a desktop shortcut by Innosetup? It's created by previous version
As a follow up to my previous question Testing on different version of Mac
Since CS3 doesn't have a web service component, as previous versions had, is there
The following is the code i used in a program - over here the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.