1

I'm using Mapstraction and trying to draw polygon by invoking map.addFeature('polygon');

It shows the exception Uncaught TypeError: Object [object Object] has no method 'addFeature'

Why am getting this exception?

JS Code:

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);
Venkat Maridu
  • 892
  • 3
  • 22
  • 45
  • Firstly try `console.log(map);` to see what `map` is actually set to. Are you sure that it is what you expect? – mibbler Jul 02 '13 at 11:11
  • I'm not familiar with Mapstraction, but I've just taken a look at the API docs and can't find a reference to the `addFeature` function. Is this part of Mapstraction or something else? – mibbler Jul 02 '13 at 11:16
  • Already checked console `console.log(map);` and its throws that exception. – Venkat Maridu Jul 02 '13 at 11:47
  • [Take a look](http://mvn.idelab.uva.es/idelabmapstraction/interactive_examples/google.features.html) – Venkat Maridu Jul 02 '13 at 11:47
  • 1
    So, that link is what you are following to create your own map? If you look at the source of that page at this file http://mvn.idelab.uva.es/idelabmapstraction/downloads/1.0/idelabmapstraction.js you can see that they are augmenting Mapstraction by creating an additional class called MapstractionInteractive, which you would need to do in order to access the `addFeature` function. – mibbler Jul 02 '13 at 11:55
  • solved it. Thank you. :) – Venkat Maridu Jul 04 '13 at 09:04

0 Answers0