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

Need for more map options #76

Closed iRonin closed 13 years ago

iRonin commented 13 years ago

Me again :)

Would you consider adding more map options or to make map initialization more flexible? I need for instance to add a scale control to my map. It can be done only on map initialization. This parameter is not currently present in gem's map options nor I can use callback function.

Perhaps one could pass a hash that would be translated 1:1 to google.maps.MapOptions making initialization ultimately flexible, what do you think?

apneadiving commented 13 years ago

Yep, could be done. Something like:

 <%= gmaps(:map_options => { :raw => json } ) %>
iRonin commented 13 years ago

Should do! If you'd like to keep the naming present currently in your code I'd replace :raw with something like :service_map_options.

apneadiving commented 13 years ago

Was rethinking about that and I came to this conclusion:

It could end_up with the following:

 <%= gmaps(:markers => { :data => '[ {"lat": "10", "lng": "20", "title": "my title"} ]', 
                         :options => { :default => '{ "flat": true, "title": "default"}' }  } ) 
  %>

Then in the js, I could merge provided argument with defaults with precedence given to data provided.

The result of the previous example would be: {"lat": "10", "lng": "20", "title": "my title", "flat": true}.

Your point of view?

iRonin commented 13 years ago

Sounds good. Since we're discussing markers – perhaps you could do the same as for map options: make it possible to pass service marker options along, thus making things like animation possible.

apneadiving commented 13 years ago

I ended with this syntax:

 <%= gmaps(:map_options => { :raw => json } ) %>

Since foo.default leads to bug in Internet explorer.

apneadiving commented 13 years ago

doc is here: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Map-Apis

iRonin commented 13 years ago

Great! I like it a lot! Thank you very much! Coffeescript looks good as well!