openlayers 学习一

0. 用以下css可自定义控件的显示样式,其他地方均不改
http://dev.openlayers.org/releases/OpenLayers-2.10/examples/custom-style.html

       0. 自定义属性

参考
http://dev.openlayers.org/releases/OpenLayers-2.10/examples/styles-unique.html

http://hi.baidu.com/e6175423/blog/item/4084e9428a5ede1f73f05d57.html

   var context =
function(feature) {
     
     
    return feature;
     
      }
     
      var
styleMap = new OpenLayers.StyleMap();
     
   
  
     
      // create
a lookup table with different symbolizers for the different
     
      // state
values
     
      var lookup
= {};
     
     
lookup[OpenLayers.State.UNKNOWN] = {fillColor: “green”};
     
     
lookup[OpenLayers.State.UPDATE] = {fillColor: “green”};
     
     
lookup[OpenLayers.State.DELETE] = {fillColor: “red”};
     
     
lookup[OpenLayers.State.INSERT] = {fillColor: “orange”};

     
     
styleMap.addUniqueValueRules(“default”, “state”, lookup,
context);
     
      layer =
new OpenLayers.Layer.Vector(‘Points’, {
     
     
    styleMap: styleMap
     
      });
     
   
  
//实现:构造自定义属性
tAtt={};
tAtt[‘speed’]=tspeed;
tAtt[‘time’]=ttime;
tAtts = OpenLayers.Util.extend({img:’Img/car_normal.png’
,vehicleNumber:name.toString() ,angle: tdirection},
tAtt); 
features.push( new OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Point(tLonLatT.lon,tLonLatT.lat),
   
tAtts
));  

0. 直接绘制轨迹可以用以下格式:
http://dev.openlayers.org/releases/OpenLayers-2.10/examples/highlight-feature.html

     
      var
feature = new OpenLayers.Feature.Vector(
     
     
   
OpenLayers.Geometry.fromWKT(
     
     
     
  “POLYGON((28.828125 0.3515625, 132.1875
-13.0078125, -1.40625 -59.4140625, 28.828125 0.3515625))”
     
     
    )
     
      );
     
     
vectors.addFeatures([feature]);
0. feature高亮选中
http://dev.openlayers.org/releases/OpenLayers-2.10/examples/highlight-feature.html

     
      var
highlightCtrl = new OpenLayers.Control.SelectFeature(vectors,
{
     
     
    hover: true,
     
     
    highlightOnly: true,
     
     
    renderIntent:
“temporary”,
     
     
    eventListeners: {
     
     
     
  beforefeaturehighlighted: report,
     
     
     
  featurehighlighted: report,
     
     
     
  featureunhighlighted: report
     
     
    }
     
      });

     
      var
selectCtrl = new OpenLayers.Control.SelectFeature(vectors,
     
   

转载自:https://blog.csdn.net/ZHANGHUI3239619/article/details/78746861

You may also like...