diff --git a/.gitignore b/.gitignore index 42b60260f3..0f81cf6d15 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ /doc/apidocs/ /examples/example-list.js /examples/example-list.xml +/examples/graphic-name.js +/examples/graphic-name.html diff --git a/examples/graphic-name.js b/examples/graphic-name.js index 654a4c997d..267ae071dc 100644 --- a/examples/graphic-name.js +++ b/examples/graphic-name.js @@ -34,14 +34,14 @@ function init(){ var styles = new OpenLayers.StyleMap({ "default": { graphicName: "${type}", - pointRadius: 10, + pointRadius: 40, strokeColor: "fuchsia", strokeWidth: 2, fillColor: "lime", fillOpacity: 0.6 }, "select": { - pointRadius: 20, + pointRadius: 50, fillOpacity: 1, rotation: 45 } diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index da82e1d7f9..e180ef7288 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -786,7 +786,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { * layer. */ getFeatureIdFromEvent: function(evt) { - var feature; + var featureId, feature; if (this.hitDetection) { // this dragging check should go in the feature handler if (!this.map.dragging) { @@ -797,7 +797,14 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { if (data[3] === 255) { // antialiased var id = data[2] + (256 * (data[1] + (256 * data[0]))); if (id) { - feature = this.features["OpenLayers.Feature.Vector_" + (id - 1 + this.hitOverflow)][0]; + featureId = "OpenLayers.Feature.Vector_" + (id - 1 + this.hitOverflow); + try { + feature = this.features["OpenLayers.Feature.Vector_" + (id - 1 + this.hitOverflow)][0]; + } catch(err) { + // Because of antialiasing on the canvas, when the hit location is at a point where the edge of + // one symbol intersects the interior of another symbol, a wrong hit color (and therefore id) results. + // todo: set Antialiasing = 'off' on the hitContext as soon as browsers allow it. + } } } }