Skip to content

Commit

Permalink
Added a way to provide scaledSize for markers
Browse files Browse the repository at this point in the history
  • Loading branch information
laalex committed Dec 9, 2015
1 parent 06c0018 commit 0a39a52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions lib/gmaps4rails/markers_builder.rb
Expand Up @@ -15,8 +15,10 @@ module Gmaps4rails
# marker.infowindow render_to_string(:partial => "/users/my_template", :locals => { :object => user}).gsub(/\n/, '').gsub(/"/, '\"')
# marker.picture({
# :url => "http://www.blankdots.com/img/github-32x32.png",
# :width => "32",
# :height => "32"
# :width => "64",
# :height => "64",
# :scaledWidth => "32", # Scaled width is half of the retina resolution; optional
# :scaledHeight => "32", # Scaled width is half of the retina resolution; optional
# })
# marker.title "i'm the title"
# marker.json({ :id => user.id })
Expand Down
19 changes: 12 additions & 7 deletions vendor/assets/javascripts/gmaps/google/builders/marker.coffee
Expand Up @@ -13,6 +13,8 @@ class @Gmaps.Google.Builders.Marker extends Gmaps.Objects.BaseBuilder
# url
# width
# height
# scaledWidth
# scaledHeight
# shadow
# anchor: [x,y]
# url
Expand Down Expand Up @@ -72,14 +74,17 @@ class @Gmaps.Google.Builders.Marker extends Gmaps.Objects.BaseBuilder

@constructor.CACHE_STORE[picture_args.url]

_picture_args: (picture_name)->
{
url: @args[picture_name].url
anchor: @_createImageAnchorPosition @args[picture_name].anchor
size: new(@primitives().size)(@args[picture_name].width, @args[picture_name].height)

_picture_args: (picture_name) ->
return_args =
url: @args[picture_name].url
anchor: @_createImageAnchorPosition @args[picture_name].anchor
size: new(@primitives().size)(@args[picture_name].width, @args[picture_name].height)
scaledSize: null
origin: null
}
origin: null
if @args[picture_name].scaledWidth and @args[picture_name].scaledHeight
_.extend return_args, scaledSize: new(@primitives().size)(@args[picture_name].scaledWidth, @args[picture_name].scaledHeight)
return_args

_createImageAnchorPosition : (anchorLocation) ->
return null unless _.isArray anchorLocation
Expand Down

0 comments on commit 0a39a52

Please sign in to comment.