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

Added support for Marker With Label library #337

Closed steveo7 closed 11 years ago

steveo7 commented 11 years ago

Added support for the markerWIthLabel library from Google Maps Utility Library V3. See this link for a reference. http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.8/docs/reference.html

example: http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.8/examples/basic.html

I added access to labelContent and labelClass marker properties to set from controller code like so;

@json = User.all.to_gmaps4rails do |user, marker|
  marker.title("My title")
  marker.labelContent("My label content")
  marker.json({labelClass: "user_marker_labels"})
end

In your view, turn on by adding :marker_with_label to your marker options then you can add other markerWithLabel properties using the raw option like so;

gmaps(map_options: {...}, markers: {data: @json, options: { marker_with_label: true, ...},
        raw: '{labelStyle: {opacity: 0.75}, labelAnchor: new google.maps.Point(22, 0)}'}})    
steveo7 commented 11 years ago

I'll do some refactoring as soon as I can. Thanks for considering this pull request!

steveo7 commented 11 years ago

Okay Ben, I removed the two unnecessary edits and made marker with label conditional with a :marker_with_label marker option. Let me know if you think it needs more work. Chao!

apneadiving commented 11 years ago

Sorry guys I've completely changed the gem in v2.

Your code isnt lost though, you'll see you can inject your own builders to adapt to what you really need

Thanks