apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Polyline when :provider => "openlayers" #216

Closed atejeda closed 12 years ago

atejeda commented 12 years ago

As was suggested in https://github.com/apneadiving/Google-Maps-for-Rails/issues/215

I've added polyline for openlayer. The json structure to use is the same used for google maps (as provider), same thing for the styling.

I've used the same example of "Display Everything.."

<%= 
gmaps({ 
"map_options" => { :provider => "openlayers", "zoom" => 2, "auto_adjust" => true }, 
"markers"     => { "data" => '[{ "description": "", "title": "", "lng": "5.9311119", "lat": "43.1251606", "picture": "", "width": "", "height": "" } ,{   "description": "", "title": "", "lng": "2.3509871", "lat": "48.8566667", "picture": "", "width": "", "height": "" } ]',
                                     },
"polylines"   => { "data" => ' [ [
                     {"lng": -122.214897, "lat": 37.772323},
                     {"lng": -157.821856, "lat": 21.291982},
                     {"lng": 178.431, "lat": -18.142599},
                     {"lng": 153.027892, "lat": -27.46758}
                     ],
                     [
                     {"lng": -120.214897, "lat": 30.772323, "strokeColor": "#000", "strokeWeight" : 2 },
                     {"lng": -10.821856, "lat": 50.291982}
                     ] ]' }
}) %>

A basic preview (pic): http://i49.tinypic.com/34o3rdh.png

apneadiving commented 12 years ago

Looks great, will test soon but merge now, thanks!