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

  • Home
  • SEARCH
  • 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 8911649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:00:00+00:00 2026-06-15T04:00:00+00:00

I developed a canvas visualization of OpenStreetMaps by means of miscellaneous scripts and rendering

  • 0

I developed a canvas visualization of OpenStreetMaps by means of miscellaneous scripts and rendering algorithms from the internet. On top of this I have a Kinetic Stage which draws custom objects which cannot be drawn by the functionality of Openlayers.

Openlayers provides many functions which I want to use and therefore I’m trying to switch over to this framework. I’m currently stuck with the event propagation, because I don’t know how to propagate an event to Openlayers.

index.html

<div id="canvasdiv">
  <div id="KineticDiv"> </div>
  <div id="OLMapDiv"> </div>
</div>

style.css

#KineticDiv {
  position: absolute;
  z-index: 1000;
}
#OLMapDiv {
  position: absolute;
  width: 1000px;
  height: 600px;
  z-index: 0;
}

ol.js

function OpenLayersMap(divname) {
  var osmLayer = new OpenLayers.Layer.OSM("Open Street Maps",
    ["http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
     "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
     "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"]);
                                        ]);
  var gmLayer = new OpenLayers.Layer.Google("Google Maps");
  var proj = new OpenLayers.Projection("EPSG:4326");

  OpenLayers.ImgPath = "/static/img/";

  this.map = new OpenLayers.Map({
    div: divname,
    allOverlays: false,
    theme: null,
    controls: [
      new OpenLayers.Control.Attribution(),
      new OpenLayers.Control.Navigation(),
      new OpenLayers.Control.LayerSwitcher(),
      new OpenLayers.Control.PanZoomBar(),
      new OpenLayers.Control.ScaleLine(),
      new OpenLayers.Control.MousePosition({
        displayProjection: proj
      }),
      new OpenLayers.Control.KeyboardDefaults()
      ]
  });
  this.map.addLayers([osmLayer, gmLayer]);
  this.map.setCenter(
    new OpenLayers.LonLat(8.56, 50).transform(proj, this.map.getProjectionObject()), 10
  );
}

OpenLayersMap.prototype = {
  constructor: OpenLayersMap
}

main.js

function main() {
  var self = this;
  this.olmap = new OpenLayersMap("OLMapDiv");
  this.kinetic = new KineticStage("KineticDiv");

  $("div#canvasdiv").bind("mouseout", function(event){
// TODO self.olmap.mouseOut(event);
  }).bind("mouseup", function(event){
// TODO self.olmap.mouseUp(event);
  }).bind("mousedown", function(event){
// TODO self.olmap.mouseDown(event);
  }).bind("mousewheel", function(event, delta){
// TODO self.olmap.mouseWheel(event, delta);
  }).bind("touchmove", function(event){
// TODO self.olmap.touchMove(event);
  }).bind("touchstart", function(event){
// TODO self.olmap.touchStart(event);
  }).bind("touchend", function(event){
// TODO self.olmap.touchEnd(event);
  });
}

Due to a higher z-index of the Kinetic Stage the event is recognized there. The event propagation is only stopped if a Kinetic Shape is hit!

Is there any suitable method in Openlayers which accepts events? (I found OpenLayers.Events.triggerEvent, but I didn’t succeed with it)

  • 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-06-15T04:00:01+00:00Added an answer on June 15, 2026 at 4:00 am

    I came up with a solution which is almost satisfying. Only a few events have to be handled by the user. Replacing the TODO’s with

    self.olmap.map.events.handleBrowserEvent(event);
    

    enables the drag&drop function on the map. Here is an example how to handle the mousewheel event:

    // main.js
    $("div#canvasdiv").bind("mousewheel", function(event, delta){
       self.olmap.zoom(event, delta);
    })
    
    // ol.js
    zoom : function(event, delta) {
        if(this.zoomExpireTime && this.zoomExpireTime == 0) {
            this.zoomExpireTime = event.timeStamp - 1;
        }
        if(this.zoomExpireTime < event.timeStamp) {
            this.map.zoomTo(this.map.getZoom() + delta);
            this.zoomExpireTime = event.timeStamp + 500;
        }
    }
    

    The controls of OpenLayers cannot be used, because they only react on click events and not on mousedown ones. I tried to convert the mousedown event to a click one, but then the drag&drop didn’t work anymore. Thus, I did a workaround which raises only the controls to the top as follows:

    var z = parseInt($("div#KineticDiv").css("z-index")) + 100;
    $("div[id=OpenLayers\\.Control\\.LayerSwitcher_8]").css("z-index", z);
    $("div[id=OpenLayers\\.Control\\.LayerSwitcher_8]").appendTo($("div#canvasdiv"));
    $("div[id=OpenLayers\\.Control\\.PanZoomBar_9]").css("z-index", z);
    $("div[id=OpenLayers\\.Control\\.PanZoomBar_9]").appendTo($("div#canvasdiv"));
    

    So this is my first scratch solution, but I think there is potential to improve it …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a game but this is a serious problem I am facing.
I have a Android App I have developed, It has been created from a
I have a developed a application that allows users to draw simple images on
I am testing out canvas and video and I have read up on alot
I've developed a component which is a combination of a few items (canvas, labels,
I've a running graph library developed with onDraw plotting the graph using canvas.drawLine methods.
I'm porting a 2D action game from Windows Phone 7 (developed in XNA 4.0)
It has been a long time since I have developed content in Facebook, so
I have a canvas, and it is redrawn when orientation is changed. It's a
I have downloaded the sample code GLPaint from developer.Apple website to draw pictures on

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.