OpenLayers OpenLayers

Ticket #1360 (closed bug: fixed)

Opened 7 months ago

Last modified 6 months ago

SVG renderer draws features in the upperleft corner of the map pane when coordinate outside range

Reported by: ahocevar Assigned to:
Priority: minor Milestone: 2.6 Release
Component: Renderer.SVG Version: 2.5
Keywords: Cc: seb@openplans.org
State: Complete

Description

The inValidRange check in Renderer.SVG is handled correctly for rectangles, but not for circles. Removing the node (like previously even improved in #1274) is useless, because it will be re-added after calling drawGeometryNode() in Renderer.Elements. The proposed patch changes the renderer so points/circles outside the valid range will be given "" coordinates and zero radius instead of removing the node.

Attachments

1360-r6240-A0.patch (2.1 kB) - added by ahocevar on 02/12/08 21:14:30.
1360-r6496-B0.patch (1.0 kB) - added by ahocevar on 03/12/08 10:42:08.

Change History

02/12/08 21:14:30 changed by ahocevar

  • attachment 1360-r6240-A0.patch added.

02/12/08 21:15:39 changed by ahocevar

Please ignore the first patch, this was for a different ticket. The correct patch is 1360-r6240-A0.patch. All tests pass in FF.

02/26/08 19:09:55 changed by tschaub

  • state changed from Review to Commit.

Looks good.

02/26/08 19:47:55 changed by ahocevar

  • status changed from new to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [6380]) SVG renderer draws features in the upperleft corner of the map pane when coordinate outside range. r=tschaub (closes #1360)

03/11/08 16:50:43 changed by tschaub

  • status changed from closed to reopened.
  • state changed from Complete to Needs More Work.
  • resolution deleted.

Haven't taken the time to see if this is the same or a different issue, but the description matches. Take a look at this example:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
    <style type="text/css">
        #map {
            width: 512px;
            height: 512px;
            border: 1px solid gray;
        }
    </style>

    <script src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">
        var map, point;

        function init(){
            var options = {
                projection: new OpenLayers.Projection("EPSG:900913"),
                displayProjection: new OpenLayers.Projection("EPSG:4326"),
                units: "m",
                maxResolution: 20, //0.07464553542137146,
                maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
                                                 20037508, 20037508.34)
            };
            map = new OpenLayers.Map('map', options);
            var vector = new OpenLayers.Layer.Vector(
                    "Vectors",
                    {isBaseLayer: true}
            );
            map.addLayer(vector);

            var x =  -8234554.33791754;
            var y = 4981644.9249702;
            point = new OpenLayers.Feature.Vector(
                new OpenLayers.Geometry.Point(x, y)
            );
            
            map.addLayer(vector);
            vector.addFeatures([point]);
            map.setCenter(new OpenLayers.LonLat(0, 0), 5);
        }
        
        function pan(){
            map.panTo(point.geometry.getBounds().getCenterLonLat());
        }

    </script>
  </head>
  <body onload="init()">
    <h3 id="title">SVG Test</h3>
    <div id="map"></div>
    <input type="button" value="Go!" onclick="pan();"></input>
  </body>
</html>

03/11/08 16:56:40 changed by sbenthall

  • cc set to sbenthall.

03/11/08 16:59:18 changed by sbenthall

  • cc changed from sbenthall to seb@openplans.org.

03/12/08 09:25:32 changed by crschmidt

Apparently:

            node.setAttributeNS(null, "cx", "");
            console.log(node.getAttributeNS(null, "cx"));

returns "0" in the console.log call. Apparently cx cant be set to an null string? (This is in drawCircle.)

03/12/08 10:42:08 changed by ahocevar

  • attachment 1360-r6496-B0.patch added.

(follow-up: ↓ 9 ) 03/12/08 11:02:39 changed by ahocevar

  • state changed from Needs More Work to Review.

1360-r6496-B0.patch fixes the issue that the out-of-range point is shown in the upper-left corner of the map.

But unlike the VML renderer, the SVG renderer will not show the point after re-centering to the point, because it is still outside the valid coordinates ranges. This would require to redraw the layer, but the renderer does not know about the layer. We have to figure out something to fix this.

(in reply to: ↑ 8 ) 03/12/08 11:03:32 changed by ahocevar

Replying to ahocevar:

But unlike the VML renderer, the SVG renderer will not show the point after re-centering to the point, because it is still outside the valid coordinates ranges.

Actually it is not, but just recentering the map will not cause the renderer to re-check that.

03/12/08 11:22:02 changed by ahocevar

I created #1431 to track the issue described in comment:8.

03/12/08 22:02:00 changed by crschmidt

  • state changed from Review to Commit.

I think that #1431 has always been with us. Certainly, I've bumped into it before. Anyway, this looks like a fine fix for this problem, and helps alleviate part of the problem: fixing #1431 (as you pointed out) is more difficult, but can come after this.

Please commit.

03/13/08 05:49:43 changed by ahocevar

  • status changed from reopened to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [6515]) Prevent SVG renderer from drawing features in the upperleft corner of the map pane when coordinates are outside range. The fix in r6380 did not work properly. r=crschmidt (closes #1360)