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

Draw polyline #291

Closed DonIvanCorleone closed 11 years ago

DonIvanCorleone commented 11 years ago

Hi all,

i am sorry but after a couple of hours searching for a solution i came here to ask you. I haved trouble to draw polylines, on my map. All I want to show are my start and end markes and the route from start to end using polylines.

here is my code:

Controller

@result = Gmaps4rails.destination(start_end, options={}, output="pretty") @steps = Array.new @result.each do |r|

      r["steps"].each do |step|

        @steps << { :lng => step["start_location"]["lng"], :lat => step["start_location"]["lat"] }

      end

  end

View

<%= gmaps({

"map_options" => {"type" => "ROADMAP", "center_longitude" => @locations.first[:lng], "center_latitude" => @locations.first[:lat], "zoom" => 4, "auto_adjust" => true, "language" => 'de'},
"markers" => { "data" => @locations.to_json },
"polylines" => { "data" =>  @steps.to_json  }
})
%>

As already said, markers recieved by the locations array are completely fine, polylines from steps does not show anything at all. I am really desperate. Does anyone have an idea what is goind wrong?

By the way: I use the newest version (2.0.0pre)

Any help appreciated

Ivan

apneadiving commented 11 years ago

It seems your data is not properly formatted.

See here for examples: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Display-Everything%21

DonIvanCorleone commented 11 years ago

Thanks a lot for your response,

I already tried your example, but unfortunately it did not work. At least I do not see the polyline, but I do see the markers on the map. Much more interesting is, if I use the :direction option and specify :from and :to, I do see the markers AND the polyine (!) which connects both. I really have no idea what is going on and why the beahviour is somehow strange. Do you have another idea for me? Any help appreciated!

Many thanks in advance.

Cheers Ivan

apneadiving commented 11 years ago

Please provide your data, creating fixtures is too long.

Sent from my iPhone

On 17 nov. 2012, at 19:33, DonIvanCorleone notifications@github.com wrote:

Thanks a lot for your response,

I already tried your example, but unfortunately it did not work. At least I do not see the polyline, but I do see the markers on the map. Much more interesting is, if I use the :direction option and specify :from and :to, I do see the markers AND the polyine (!) which connects both. I really have no idea what is going on and why the beahviour is somehow strange. Do you have another idea for me? Any help appreciated!

Man thanks in advance.

Cheers Ivan

— Reply to this email directly or view it on GitHub.

DonIvanCorleone commented 11 years ago

I feel so sorry. I just figured out what happened. After updating the gem version i forgot to update the javascripts. I really forgot all the time. Thanks and sorry again for the inconvenience. This ticket can be closed.