wkt openlayers的缩放和高线功能?

时间:2016-01-16 15:41:43

标签: javascript openlayers postgis

我有一个WKT格式的多边形: POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))

我希望缩放此功能并将其设为高线,任何人都可以举例说明吗?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,它对我有用

function zoomByWKT(wkt){

   var feature=new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT(wkt));   
   selectVector.removeAllFeatures();
   selectVector.addFeatures([feature]);
   vectorHightlight.activate();
   vectorHightlight.select(feature);
   vectorHightlight.deactivate();
   // zoom
   map.zoomToExtent(selectVector.features[0].geometry.getBounds());

}

VectorHightline是选择控件,它会通过选择它使你的功能更高。