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

Custom markers are not displayed properly #183

Closed niuage closed 12 years ago

niuage commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

Ok, I'll try that.

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

niuage commented 12 years ago

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

apneadiving commented 12 years ago

that's what I feared...

known bug or implementation to change in the gem?

niuage commented 12 years ago

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

niuage commented 12 years ago

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 commented 12 years ago

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

niuage commented 12 years ago

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

apneadiving commented 12 years ago

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

It's always a pain to debug such issues.

niuage commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

Fiiiiiiiixed!

niuage commented 12 years ago

Thanks for your help :)

Why does raw have to be a string?

apneadiving commented 12 years ago

I love this kind of news :)

apneadiving commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

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

robertleelittleiii commented 12 years ago

Thanks, fixed it for me too.

niuage commented 12 years ago

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

robertleelittleiii commented 12 years ago

It was chrome and also saw it on safari too.

niuage commented 12 years ago

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

AhmerArif commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

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: https://github.com/apneadiving/Google-Maps-for-Rails/issues/183#issuecomment-5151489

AhmerArif commented 12 years ago

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 commented 12 years ago

I edited the markers page.

apneadiving commented 12 years ago

@AhmerArif : just answered your question on SO

rajesh2210 commented 10 years ago

@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 commented 10 years ago

all divs are not coming for google maps in gmaps4rails