Skip to content

Custom markers are not displayed properly #183

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

5 participants

@niuage
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
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
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
niuage commented Apr 10, 2012

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

@apneadiving
Owner

that's what I feared...

known bug or implementation to change in the gem?

@niuage
niuage commented Apr 10, 2012

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

@niuage
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
Owner

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

@niuage
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
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
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
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
niuage commented Apr 10, 2012

Fiiiiiiiixed!

@niuage
niuage commented Apr 10, 2012

Thanks for your help :)

Why does raw have to be a string?

@apneadiving
Owner

I love this kind of news :)

@apneadiving
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
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
niuage commented Apr 10, 2012

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

@robertleelittleiii

Thanks, fixed it for me too.

@niuage
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

It was chrome and also saw it on safari too.

@niuage
niuage commented Apr 11, 2012

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

@AhmerArif

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
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
Owner
@AhmerArif

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
niuage commented Apr 16, 2012

I edited the markers page.

@apneadiving
Owner

@AhmerArif : just answered your question on SO

@rajesh2210

@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

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
Something went wrong with that request. Please try again.