OpenLayers圈始终出现在原点

时间:2012-08-02 21:46:57

标签: javascript coffeescript openlayers

所以我设法在点击时在OpenLayers中创建一个圆圈。但是,圆圈​​始终显示在地图的原点,我希望它出现在我点击的任何地方。这是我的代码 -

 circleStyle = {
      strokeColor: "#FF0000",
      strokeOpacity: 1,
      strokeWidth: 3,
      fillOpacity: 0.8
    }

lon = mapApp.get("mapModel").get("mouse").get("longitude")
    lat = mapApp.get("mapModel").get("mouse").get("latitude")
    circleLayer = new OpenLayers.Layer.Vector "Alpr GeoSearch"
    circle = new OpenLayers.Geometry.Polygon.createRegularPolygon(
      new OpenLayers.Geometry.Point(100,100),
      10000,
      60
      )
    feature = new OpenLayers.Feature.Vector(circle,testPoint,circleStyle)
    circleLayer.addFeatures(feature)
    console.log(circleLayer)
    mapApp.map.openLayersMap.addLayer circleLayer

1 个答案:

答案 0 :(得分:0)

我在这里遗漏了什么,这句话......

new OpenLayers.Geometry.Point(100,100),

肯定是

new OpenLayers.Geometry.Point(lon,lat)

或者反过来(lat,lon),我永远不会记得。据我所知,您使用的代码是在坐标'100,100'处创建的,并且您永远不会使用您抓取的lon和lat变量。