2012-08-02 26 views
0

所以我設法在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 

回答

0

我在這裏失去了一些東西,這條線......

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

肯定應該是

new OpenLayers.Geometry.Point(lon,lat) 

或者其他方式輪(緯度,經度) ,我永遠不會記得。據我可以看到你使用的代碼是在座標'100,100'處創建的,並且你從不使用你所抓取的lon和lat變量。