码迷,mamicode.com
首页 > 其他好文 > 详细

利用OpenLayers创建wkt字符串

时间:2016-01-29 16:10:09      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

            var polygon = OpenLayers.Geometry.Polygon.createRegularPolygon(new OpenLayers.Geometry.Point(6, 49), 2, 18, 0);
            var feature = new OpenLayers.Feature.Vector(polygon);
            var wkt_c = new OpenLayers.Format.WKT();
            var wktString = wkt_c.write(feature);
            var projection = new OpenLayers.Projection("EPSG:4326");
            var testarea = polygon.getGeodesicArea(projection).toFixed(2);
            //var testarea = polygon.getGeodesicArea().toFixed(2); //default:EPSG:4326

创建出来的数据,大概是这个样子:

"POLYGON((6.027164 49.524078,6.088064 49.680508,5.948726 49.772232,5.941587 49.91943,6.03742 50.064381,6.147439 50.130783,6.211109 50.166946,6.312177 50.134426,6.340263 49.998951,6.525142 49.858585,6.734586 49.815399,6.715019 49.685902,6.603117 49.621159,6.636707 49.462303,6.57162 49.490456,6.315996 49.495625,6.027164 49.524078))"

  

  

利用OpenLayers创建wkt字符串

标签:

原文地址:http://www.cnblogs.com/xiashengwang/p/5169133.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!