views:

554

answers:

0

Hello! I have an array containing several markers for my googlemap. When I try to add this array to my map I get this error. Any ideas why?

Here is my code:

    markers = [];
    function create_station_marker(position){
          if(position != null){
            eval(position);
            var latitude = parseFloat(position.latitude);
            var longitude = parseFloat(position.longitude);

            var new_icon = new GIcon();
            new_icon.image = "marker.png";
            new_icon.size = new GSize(25,17);
            var opt;
            opt = {};
            opt.icon = new_icon;

            var marker = new GMarker(new GLatLng(latitude, longitude),opt);
            markers.push(marker);
        }
    }

And this is where I add my Array to the map:

    function load_googlemap() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(48.092757,11.645508), 4);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());


        for (var i=0; i< markers.length; i++ ) {
            try{
                map.addOverlay(markers[i]);
                alert(markers[i].toSource());

            }catch(ex){
                //here I get this error!!!
                alert(ex);
            }
        }
    }
}

Any ideas about that?