Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/462.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript OpenLayers圆始终显示在原点_Javascript_Coffeescript_Openlayers - Fatal编程技术网

Javascript OpenLayers圆始终显示在原点

Javascript OpenLayers圆始终显示在原点,javascript,coffeescript,openlayers,Javascript,Coffeescript,Openlayers,因此,我在点击OpenLayers时成功地创建了一个圆圈。但是,圆始终显示在地图的原点,我希望它显示在我单击的任何位置。这是我的密码- circleStyle = { strokeColor: "#FF0000", strokeOpacity: 1, strokeWidth: 3, fillOpacity: 0.8 } lon = mapApp.get("mapModel").get("mouse").get("longitude")

因此,我在点击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

我是不是漏掉了什么,这句话

new OpenLayers.Geometry.Point(100,100),
应该是

new OpenLayers.Geometry.Point(lon,lat)
或者反过来说,我永远记不起来了。据我所知,您正在使用的代码是在坐标“100100”处创建的,并且您从未使用您获取的lon和lat变量