问题描述
我把openlayers中的案例copy出来修改后执行了一下,在ie中没有任何问题,各种好使。换到firefox中就出现openlayers.Styleisnotaconstructor、openlayers.requestisundefined等错误,请问这是怎么回事儿?以下是代码<htmlxmlns="http://www.w3.org/1999/xhtml"><head><title>OpenLayersStyleMap</title><linkrel="stylesheet"href="theme/default/style.css"type="text/css"/><linkrel="stylesheet"href="style.css"type="text/css"/><scriptsrc="lib/OpenLayers.js"></script><scripttype="text/javascript">varmap;functioninit(){map=newOpenLayers.Map('map');varwms=newOpenLayers.Layer.WMS("OpenLayersWMS","http://vmap0.tiles.osgeo.org/wms/vmap0",{layers:'basic'});//Create50randomfeatures,andgivethema"type"attributethat//willbeusedtostylethembysize.varfeatures=newArray(50);for(vari=0;i<features.length;i++){features[i]=newOpenLayers.Feature.Vector(newOpenLayers.Geometry.Point((360*Math.random())-180,(180*Math.random())-90),{type:5+parseInt(5*Math.random())});}//CreateastyleMaptostyleyourfeaturesfortwodifferent//renderintents.Thestyleforthe'default'renderintentwill//beappliedwhenthefeatureisfirstdrawn.Thestyleforthe//'select'renderintentwillbeappliedwhenthefeatureis//selected.varmyStyles=newOpenLayers.StyleMap({"default":newOpenLayers.Style({pointRadius:"${type}",//sizedaccordingtotypeattributefillColor:"#ffcc66",strokeColor:"#ff9933",strokeWidth:2,graphicZIndex:1}),"select":newOpenLayers.Style({fillColor:"#66ccff",strokeColor:"#3399ff",graphicZIndex:2})});//Createavectorlayerandgiveityourstylemap.varpoints=newOpenLayers.Layer.Vector("Points",{styleMap:myStyles,rendererOptions:{zIndexing:true}});points.addFeatures(features);map.addLayers([wms,points]);//Createaselectfeaturecontrolandaddittothemap.varselect=newOpenLayers.Control.SelectFeature(points,{hover:true});map.addControl(select);select.activate();map.setCenter(newOpenLayers.LonLat(0,0),1);}</script></head><bodyonload="init()"><h1id="title">StyleMapExample</h1><divid="tags"></div><pid="shortdesc">ShowshowtouseaStyleMaptostylefeatureswithrulebasedstyling.AstylemapreferencesonormoreOpenLayers.Styleobjects.TheseOpenLayers.StyleobjectsarecollectionsofOpenLayers.Ruleobjectsthatdeterminehowfeaturesarestyled.AnOpenLayers.RuleobjectcombinesanOpenLayers.Filterobjectwithasymbolizer.Afilterisusedtodeterminewhetheraruleappliesforagivenfeature,andasymbolizerisusedtodrawthefeatureiftheruleapplies.</p><divid="map"class="smallmap"></div><divid="docs"><p>Astylemapisusedwithvectorlayerstodefinestylesforvariousrenderingintents.Thestylemapusedherehasstylesdefinedforthe"default"and"select"renderingintents.Thismapalsohasanactiveselectfeaturecontrol.Whenyouhoveroverfeatures,theyareselectedanddrawnwiththestylecorrespondingthethe"select"renderintent.</p></div></body></html>
解决方案
解决方案二:
接分走人