Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom markers are not displayed properly #183

Closed
niuage opened this issue Apr 10, 2012 · 29 comments
Closed

Custom markers are not displayed properly #183

niuage opened this issue Apr 10, 2012 · 29 comments

Comments

@niuage
Copy link

niuage commented Apr 10, 2012

Hey,

I just updated to the last version (1.4.8) from 1.4.3 and my custom markers are not displayed properly, as you can see in the following pic:

custom markers

This is how I customize the markers:

def gmaps4rails_marker_picture
    { picture: "/assets/map_markers/#{self.class.name}-icon#{marker_color}.png", width: "28", height: "33" }
end

Also, note that it's not only the marker image that is cut, the clickable zone is as small as the image.

Did something changed related to how I need to specify the size of the markers? I really dont know what's going on since some of the markers (the majority actually) are displayed properly.

Thanks.

@apneadiving
Copy link
Owner

Mmmm, don't really know what could be the change here.

I changed the google maps api version I require, my tests seemed fine but I can't see any other reason why this would fail.

Could you try playing with the google maps version number?

PS: I love your icon :)

@niuage
Copy link
Author

niuage commented Apr 10, 2012

Ok, I'll try that.

ps: thanks, but I did not create it, it's from this huge collection: http://mapicons.nicolasmollet.com/

@niuage
Copy link
Author

niuage commented Apr 10, 2012

Ok, it's because the google maps api version...
It's breaking from 3.7.

@apneadiving
Copy link
Owner

that's what I feared...

known bug or implementation to change in the gem?

@niuage
Copy link
Author

niuage commented Apr 10, 2012

I have no idea, I'll try to find out.

@niuage
Copy link
Author

niuage commented Apr 10, 2012

http://code.google.com/p/gmaps-api-issues/issues/detail?id=3908

Looks like this guy was having the same problem with 3.7. What makes me sad is that it's supposed to be fixed in 3.8 :( Noooo.

If you wanna take a look at the changelog: http://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIv3Changelog

Fixed:
    Regression: Scaled markers rendered incorrectly with invalid "size" parameter ( Issue 3908 )

@apneadiving
Copy link
Owner

It should not be a big deal if 3.8 is backward compatible...

@niuage
Copy link
Author

niuage commented Apr 10, 2012

The thing is, your last gmaps4rails version uses 3.8, and my icons are still messed up...
I'll try again.

@apneadiving
Copy link
Owner

sorry didn't realize... damn it! so maybe the js syntax changed a bit...

It's always a pain to debug such issues.

@niuage
Copy link
Author

niuage commented Apr 10, 2012

They seem to say that it's still not fixed in IE, and some guy is getting an error on chrome (no errors for me), and they mention that setting the "optimized" option to false solved the problem.

Also, seems like this page talks about the same solution.
http://www.gutensite.com/Google-Maps-Custom-Markers-Cut-Off-By-Canvas-Tiles

I tried that, but it didnt work:

<%= gmaps({ :map_options => map_options, :markers => { :data => map, options: { do_clustering: false, optimized: false } } }, false) %>

I guess I'll go read the doc on how to pass options to all markers.

@apneadiving
Copy link
Owner

Ok.

I was a bit fed up by the useless course to have all options so I ended up adding a raw options where you can put what you need:

<%= gmaps(:markers => {:data => @json, :options => { :raw => '{ optimized: false }' } } ) %> 

@niuage
Copy link
Author

niuage commented Apr 10, 2012

Fiiiiiiiixed!

@niuage
Copy link
Author

niuage commented Apr 10, 2012

Thanks for your help :)

Why does raw have to be a string?

@apneadiving
Copy link
Owner

I love this kind of news :)

@apneadiving
Copy link
Owner

it's a string because it's supposed to be a json hash I simply merge with the one I build from other data.

raw means raw json. I guess it's another point to standardize.

@niuage
Copy link
Author

niuage commented Apr 10, 2012

Yeah, the problem comes from the use of canvas for rendering the markers now, by default, and it seems like other map tiles are hiding the markers (that's why some of them are rendered fine, they're not overlaping). Don't know why it does not work on my chrome though.

@niuage
Copy link
Author

niuage commented Apr 10, 2012

I see :)
Anyways, it all worked out, I didnt want to downgrade for that bug.

@robertleelittleiii
Copy link

Thanks, fixed it for me too.

@niuage
Copy link
Author

niuage commented Apr 11, 2012

What browser are you using? Just curious to see if I'm the only with this problem on chrome ^^.

@robertleelittleiii
Copy link

It was chrome and also saw it on safari too.

@niuage
Copy link
Author

niuage commented Apr 11, 2012

Ok, thanks. I have no idea how they thought it was fixed in 3.8 then...

@AhmerArif
Copy link

Just wanted to add that I was having this problem with my custom marker icons until I switched from:

marker.picture
({
:picture => picture_path,
:width => "32",
:height => "37"
})

to

marker.picture
({
:picture => picture_path,
:width => 32,
:height => 37
})

@niuage
Copy link
Author

niuage commented Apr 16, 2012

You're right, it works! No need for optimized: false when using integers.

The doc should be edited then: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Markers

Thanks :)

@apneadiving
Copy link
Owner

Good to hear, could you update the wiki please?

Sent from my iPhone

On 16 avr. 2012, at 14:53, niuagereply@reply.github.com wrote:

You're right, it works! No need for optimized: false when using integers.

The doc should be edited then: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Markers

Thanks :)


Reply to this email directly or view it on GitHub:
#183 (comment)

@AhmerArif
Copy link

Done (https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Controller).

Hey apneadiving, could you take a look at my stack-overflow question regarding infowindows for polygons? :D

http://stackoverflow.com/questions/10170883/polygon-infowindows-in-gmaps4rails

@niuage
Copy link
Author

niuage commented Apr 16, 2012

I edited the markers page.

@apneadiving
Copy link
Owner

@AhmerArif : just answered your question on SO

@rajesh2210
Copy link

@apneadiving
i am using google maps for my project in rails 4, ruby 2, and gmaps4rails '1.5.6' but the problem is i am not getting marker at center of the map as well as the zoom in zoom out side bar is also not coming.

If any one have any idea about this problem please reply?

Model Action
acts_as_gmappable

def gmaps4rails_address
html = full_address(city_id,state_id,country_id)
self.location = (location + html)
location
end

def full_address(city_id,state_id,country_id)
city_name = MdmCity.get_city_name(city_id)
state_name = MdmState.get_state_name(state_id)
country_name = MdmCountry.get_country_name(country_id)
html = "#{city_name} #{state_name} #{country_name}"
html
end

Controller Action

def edit_content
@location_json = SeoContent.where(:id => params[:id]).first.to_gmaps4rails
end

VIEW

<%= gmaps4rails(@location_json) %>

Issues for me.

  1. Zoom In and Zoom out bar is not coming.
  2. Marker is not coming at center.
  3. How to give Info window.
  4. How to raise that address is Invalid, which is not present on google map (Eg:kdjfkdfhdkfhd)
  5. Why this action (def gmaps4rails_address) is calling automatically.
  6. I want to call def gmaps4rails_address from update action too how ?
  7. Can i show directions on map ?

Thanks

@rajesh2210
Copy link

all divs are not coming for google maps in gmaps4rails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants