本节使用官网例子学习OpenLayers绘图是使用过滤器,即按照指定的规则进行符号化。主要代码如下:
<script type="text/javascript">
var map;
function init() {
map = new OpenLayers.Map("map", { controls: [] });
var wms = new OpenLayers.Layer.WMS("wmsName",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{ layers: "basic" });
map.addLayer(wms);
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.PanZoom());
map.zoomToMaxExtent();
// 自动检测不同的渲染器
var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderer;
var layer = new OpenLayers.Layer.Vector("simple geometry", {
styleMap: new OpenLayers.StyleMap({
"default": new OpenLayers.Style(null, {
rules: [
new OpenLayers.Rule({