views:

80

answers:

1

I'm using Ym4r and want to add a polyline to my map.

This works:

polyline = GPolyline.new([[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]],"#ff0000",3,1.0)
@map.record_init @map.add_overlay(polyline)

But this doesn't:

polystring = "[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]"
polyline = GPolyline.new([polystring],"#ff0000",3,1.0)
@map.record_init @map.add_overlay(polyline)

Any idea why? Regards Arwed

+1  A: 

From the code given it shows that GPolyline.new accept 1st parameter as an array (aray of array) so try this

polystring = [[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]]
polyline = GPolyline.new(polystring,"#ff0000",3,1.0)
@map.record_init @map.add_overlay(polyline)

also

   polystring = "[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]"
   arr1= [polystring]
   arr2= [[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]]

then arr1[0] = "[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]" where as 
     arr2[0] = [27.4037755983,89.4263076782]
Salil
thx. you made my day
Arwed