[OpenLayers-Dev] 回复: ??: openlayers problem in IE6

Eric Lemoine eric.c2c at gmail.com
Tue Oct 21 03:08:09 EDT 2008


2008/10/20 dequan chen <cdqrain at gmail.com>:
> hi Matthias Pohl. thanks
>
> sorry for forgetting to mention that if you remove <!DOCTYPE html
> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> or just
> remove the segment of
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" from the
> page. IE7 FF will not work too.
> So, I think IE6 do not according to the W3C standard even though we
> add this DOCTYPE in page.
>
> var map = new OpenLayers.Map('map');
>            var layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
>                    "http://labs.metacarta.com/wms/vmap0", { layers: 'basic' });
>            map.addLayer(layer);
>            map.addControl(new OpenLayers.Control.LayerSwitcher());
>
>            var lineLayer1 = new OpenLayers.Layer.Vector("Line Layer");
>            var pts = [];
>            pts.push(new OpenLayers.Geometry.Point(0, 1));
>            pts.push(new OpenLayers.Geometry.Point(12, 50));
>            var line = new OpenLayers.Feature.Vector(new
> OpenLayers.Geometry.LineString(pts), null,
> OpenLayers.Feature.Vector.style['default']);
>            lineLayer1.addFeatures([line]);
>            lineLayer1.events.register("mouseover", lineLayer1, function(e) {
>                this.div.style.cursor = "pointer";
>                var feature = this.getFeatureFromEvent(e);
>                if (feature)
>                    alert("LineLayer1");
>            });
>            var lineLayer2 = new OpenLayers.Layer.Vector("Polygon Layer");
>            var pts = [];
>            pts.push(new OpenLayers.Geometry.Point(-70, -10));
>            pts.push(new OpenLayers.Geometry.Point(12, 50));
>            var line = new OpenLayers.Feature.Vector(new
> OpenLayers.Geometry.LineString(pts), null,
> OpenLayers.Feature.Vector.style['default']);
>            lineLayer2.addFeatures([line]);
>            lineLayer2.events.register("mouseover", lineLayer2, function(e) {
>                this.div.style.cursor = "pointer";
>                var feature = this.getFeatureFromEvent(e);
>                if (feature)
>                    alert("LineLayer2");
>            });
>            map.addLayer(lineLayer1);
>            map.addLayer(lineLayer2);
>
>            map.setCenter(new OpenLayers.LonLat(0, 0));
>
> this code tests success in IE7 and FF, but not in IE6.
> if i remove DOCTYPE, all of the browsers do not work. only top vector
> layer event triggered.

I've just tried your code (see attached file) in FF3 and IE7 with the
DOCTYPE. It doesn't work in FF3 (alert("LineLayer1") does not
trigger), but works in IE7. Are you sure this is IE6 not behaving
correctly? Or could it be IE7 not behaving expectingly?

--
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20081021/3dd01009/multi-vector-layers-2.html


More information about the Dev mailing list