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

Polylines when :provider => "openlayers" #215

Closed atejeda closed 12 years ago

atejeda commented 12 years ago

I've tried with no success the polyline feature with openlayers as a provider, I know there's un-implemented features but is not clear to me how many of these features are implemented in openlayers, i.e.: polyline.

The thing is I just want to draw a line from a point to another point (lat, lon), I guess this feature can provide that. If not, I'm trying to modifying the code, draw a line from the first point to the others (lat, lon) points.

My json data is :

[{"lng":-70.5838,"lat":-33.5241},{"lng":-70.5841,"lat":-33.5226}] 

code:

<%= gmaps(
"polylines" => { :data => @locations, "options" => { "draggable" => true } },
 "map_options" =>  { :provider => "openlayers", "auto_adjust" => "true", "detect_location" => false, "center_on_user" => false }, 
 :last_map => true ) 
  %>

I´ve an idea, but before trying to develop (see http://stackoverflow.com/questions/2735944/drawing-a-path-with-a-line-in-openlayers-using-javascript) I want to know if is possible to get this in some way with the actual implementation using OpenLayers as a dataprovider.

apneadiving commented 12 years ago

I confirm polylines aren't implemented in the gem for Openlayers right now. See here.

To implement it, you should abstract the polyline construction here and move different implementations in googlemaps and openlayers js files

atejeda commented 12 years ago

Thanks, I'll try it.

atejeda commented 12 years ago

I've implemented polyline for openlayers, check https://github.com/apneadiving/Google-Maps-for-Rails/pull/216