我正在使用Ym4r并希望在我的地图上添加折线。
这有效:
polyline = GPolyline.new([[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]],"#ff0000",3,1.0)
@map.record_init @map.add_overlay(polyline)
但这不是:
polystring = "[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]"
polyline = GPolyline.new([polystring],"#ff0000",3,1.0)
@map.record_init @map.add_overlay(polyline)
知道为什么吗? 问候 Arwed
答案 0 :(得分:1)
从给出的代码中可以看出,GPolyline.new接受第一个参数作为数组(数组的aray),所以试试这个
polystring = [[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]]
polyline = GPolyline.new(polystring,"#ff0000",3,1.0)
@map.record_init @map.add_overlay(polyline)
也
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]