未捕获的TypeError:对象[object Object]没有方法'addFeature'

时间:2013-07-02 11:06:39

标签: javascript maps openlayers mapstraction

我正在使用Mapstraction并尝试通过调用map.addFeature('polygon');

来绘制多边形

它显示了异常 Uncaught TypeError: Object [object Object] has no method 'addFeature'

为什么会遇到此异常?

JS代码:

var polyPoint;
    var polyPoints = []

    //Adding polygon to map
    polyPoint = new mxn.LatLonPoint(17.447612 , 78.223686)
    polyPoints.push(polyPoint);
    polyPoint = new mxn.LatLonPoint(17.504593 , 78.306084)
    polyPoints.push(polyPoint);
    polyPoint = new mxn.LatLonPoint(17.471193 , 78.417320)
    polyPoints.push(polyPoint);
    polyPoint = new mxn.LatLonPoint(17.414201 , 78.470879)
    polyPoints.push(polyPoint);


    var polygon = new mxn.Polyline(polyPoints);
    polygon.setClosed(true);
    map.addPolyline(polygon)
    map.addFeature('polygon', polyPoints);

0 个答案:

没有答案