简体   繁体   English

OpenLayers圈子始终出现在原点

[英]OpenLayers circle always appears at origin

So I have managed to create a circle in OpenLayers on click. 因此,我已经设法在OpenLayers上单击创建一个圆。 However, the circle always appears at the origin of the map, I want it to appear wherever I click. 但是,圆圈​​始终出现在地图的原点,我希望它显示在我单击的任何位置。 This is my code - 这是我的代码-

 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

Am I missing something here, this line... 我在这里错过了什么吗?

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

Should surely be 应该是

new OpenLayers.Geometry.Point(lon,lat)

Or the other way round (lat,lon), I can never remember. 或反过来(拉特,lon),我不记得了。 As far as I can see the code you are using is creating at point at coordinates '100,100', and you are never using your lon and lat variables you have grabbed. 据我所见,您正在使用的代码是在坐标“ 100,100”处创建的,并且您从未使用过已获取的lon和lat变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM