apneadiving / google-maps-for-rails Goto Github PK
View Code? Open in Web Editor NEWEnables easy Google map + overlays creation in Ruby apps
Home Page: https://apneadiving.github.io/
License: MIT License
Enables easy Google map + overlays creation in Ruby apps
Home Page: https://apneadiving.github.io/
License: MIT License
hi there,
thanks for the work on the gem! followed instructions (production env has config.serve_static_assets = true). but apache serves the js, stylesheet, and the marker file as empty.
using apache 2.2.17, rails 3.0.4, gmaps4rails 0.3
in fact, what config.serve_static_assets is set to makes no difference. i get no errors in the production log, or apache logs, and if i try to fetch the files directly (/images/marker.png, for instance), they come back empty
is the gem not being able to find the bundled files? permission issue?
thanks in advance
What about a process_reverse_geocoding
method? Anybody needs it?
I would suggest to add a google.setOnLoadCallback that triggers the Gmaps4Rails.initialize();
In order to avoid this error:
Error: google.maps.LatLng is not a constructor
Source File: http://127.0.0.1:3000/javascripts/gmaps4rails.js?1301301217
Line: 91
I figured you would ask me to post to stack overflow, so I went there first :)
Not getting any action there - any idea what causes this??
troy$ rake populate:scans --trace
** Invoke populate:scans (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute populate:scans
http://goo.gl/fb/977ze
Sat, 16 Jul 2011 19:43:59 GMT
47.676506
-122.121872
91df0f32209c5212bdfd09de5ff0d25dce816596
rake aborted!
undefined method `gmaps' for #Scan:0x000001051fb9a8
I've set up auto detect location in my view according to the wik, but it just continues to show a map of the world and never attempt to retrieve the user's location. Perhaps I am doing it wrong?
<%= gmaps4rails({ "map_options" => { "container_id" => "connections_map_container", "auto_adjust" => "true", "detect_location" => "true", "center_on_user" => "true" } })%>
This is a fantastic tool which made adding maps to our application very easy. Thanks guys!
The only problem I'm hitting now is that if you use it on an https page, then you get security warnings about mixed content. The google maps api does support https, so I think it's just a question of changing the script references from http to https. Unfortunately I think it's hidden behind the "acts_as_gmappable" statement - I was hoping for a content_for block I could modify.
Is there an easy way to make it use the https version of the API?http://code.google.com/apis/maps/documentation/javascript/basics.html#HTTPS
Many thanks,
Alex
guys - here is another suggestion. as you probably know, google api doesn't let you display multiple markers that have identical coordinates (i.e., several people living in the same apartment building, etc.). as far as i know, clustering doesn't solve this either.
here is one workaround - to just slightly adjust the coordinates of some markers (by10 or more meters) to display them all on the map. i don't have a pull request, but here is the link to my code: https://gist.github.com/873142 , and here is a link to a relevant discussion: http://stackoverflow.com/questions/2151250 .
i think this would be a good optional feature to have.
cheers
First of all thanks for creating Gmaps4rails!
After reading the wiki and trying to read the code (I'm not a dev, so I might missed it), I can't find a way to define the center (long and lat) and the zoom to "auto".
Is this possible with Gmaps4rails right now?
Thanks in advance,
Emiliano
You can close this if you like, just wanted to share my observations on some design limitations and missing features to an otherwise very nice library. I was hoping to use your library and when I tried it out I found the following issues:
There are a number of things I like about your library that are better than Cartographer. I didn't want to try and add any of those features as it would require significant API changes. What are your thoughts/plans for the library and these features?
Hello,
Since model.gmaps4rails_options
returns a new hash each time it's called one cannot modifying an including instance's options. This makes sense though, as most of the options shouldn't be modified, but how can one easily run their unit tests without using real addresses or installing a mock lib.
Factory.define :event do |e|
# ...
e.after_build do |ev|
ev.gmaps4rails_options[:validation] = false if ev.respond_to? :gmaps4rails_options
end
end
Instead I've had to do the more invasive: acts_as_gmappable :validation => !Rails.env.test?
Maybe there's a better way?
Im trying to do a click on map that shows some info. Im using google API's
Gmaps4Rails.callback = function() {
google.maps.event.addListener(map, "click", function() {
alert("You clicked the map.");
});
};
but this is not working, It doesnt no anything
I open this issue in parallel with the one "Support for Mongoid".
I'm developing an application that uses this nice gem: https://github.com/kristianmandrup/mongoid-geo
This gem enables you to write something like this:
class Person
field :location, :type => Array, :geo => true, :lat => :latitude, :lng => :longitude
geo_index :location
end
This way, the object Person
gains the instance methods .latitude
and .longitude
. Nice! (read the readme for further details https://github.com/kristianmandrup/mongoid-geo)
The problem is that, in method Gmaps4rails.create_json(object)
, this call object[object.gmaps4rails_options[:lat_column]]
returns nil
, because mongoid_geo simply adds the convenience method .latitude
, but doesn't create a field latitude
: so object[:latitude]
is nil
.
So, is it possible to change object[object.gmaps4rails_options[:lat_column]].blank?
in something like object.send(object.gmaps4rails_options[:lat_column]).blank?
Is something useless for all of you, and so I simply fork this gem for myself? Or you can do this little patch and push it in this main repository?
Can you please do something about the screencasts that you have? I cannot see them at all on the Macbook Pro if I go to the full screen mode and they are quite difficult to see in the original size?
It would be nice if you just posted the source code for your screencasts?
Thanks.
Bharat
When using this plugin on sites that use SSL the maps are being pulled from non secure resources and it's throwing an error on load, specifically in IE.
Chrome doesn't throw an error, just has a warning in the URL bar, FF removes the color box indicating all content is still from a secure source.
Any clue on if there's a way to make the resources pull from https instead?
when assigning values under map_options: { } this values are not working
same when using
<%= gmaps("map_options" => { "detect_location" => false, "center_on_user" => false, "zoom" => 18},"markers" => { "data" => @JSON }) %>
it just uses the default values, for example, zoom = 6
Hi there:
I am very interested in this map plugin. Just wonder, that can it draw any lines or something else onto the map, or it's yet to be implemented? (cuz I didn't see it in the wiki) Thanks very much.
How is it possible to add custom action Listener to Markers?
Doesn't seem like this works in Rails 3.1 (3.1.0.rc4). Even if I copy over the js and css files from source I get a javascript error deep inside of google's code. ("TypeError: Result of expression 'a' [null] is not an object.")
Any ETA on when a 3.1 candidate might be available?
Thanks
I encountered both issues from the title while attempting to populate markers based on the user's current geolocation, as provided by the browser. Details in the following Stack Overflow post:
Following that page on the wiki - I have this in my view:
<%= gmaps4rails(@json,{
"map_options" => {"detect_location" => "true", "center_on_user" => "true"}
})%>
the @JSON is my data.. the map works, but it doesn't ask me for permission - or show my location. Any idea what is missing?
Hi there: I just noticed that possibly before 0.4 the mark is based on lat and long, and in version 0.5 there's a big change. Address is not allowed to be null and the lat and long are automatically adjusted based on the address, even if I want to change it manually. I wish to have a feature that marks somewhere directly on the map using lat and long, instead of address. or maybe it could be describes as, make address and coordination independent and mark either one separately? Thanks very much.
added custom infobox to my app with your 0.8.7 gem. all is working well in chrome, ff, and safari, but not on ipad/iphone. the markers seem not to be clickable. any ideas.
this gem is awesome. thanks for your hardwork!
miguel
Hi it's me again :-P.
I have been playing a bit with the custom infobox you added lately and I realized that if more than one marker is loaded on the map when you click on all of them the box is not closed automatically when a new marker is selected.
Probably you still want to use your openInfoWindow function in your gmaps4rails.js, something like:
create_info_window:
...
var ib = new InfoBox(gmaps4rails_infobox(boxText));
google.maps.event.addListener(marker_container.google_object, "click",
this.openInfoWindow(ib, Gmaps4Rails.map, marker_container.google_object));
...
Instead of calling ib.open, which doesn't appear to handle the closure of the previous marker.
Also, I personally don't find the option "custom_infowindow_status" => "opened" useful, if you have only one marker it can make sense but if you have more the map can end up really confused.
Hope this helps.
Gianluca
Any plan?
Hi, I am trying to disable the UI from the map as follow, but it's not taken into account:
<%= gmaps({
"map_options" => { "disableDefaultUI" => true, "type" => "ROADMAP", "zoom" => 15, "auto_adjust" => true, "auto_zoom" => false, "container_id" => "side_map", } ,
"markers" => { "data" => @GMAP }
} ) %>
Am I doing it the wrong way ?
Thanks.
How to set a custom icon for clusters?
Displaying the default or any other markers seems to be broken when upgrading from 0.9.x to 0.10.0.
They do not display when called, even though the Firebug correctly shows them up as created.
Downgrading to 0.9.0 or 0.9.1 displays them again.
I wish I could add this feature myself, but I need to improve my ruby on rails knowledge first. Do you have any plan of developing something like the InfoBox you can see here http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries ?
Only when i use Uservoice (http://uservoice.com) script widget on my website here is the error I see :
Uncaught TypeError: Property 'l' of object [object DOMWindow] is not a function
imarkerclusterer_compiled.js :1
Gmaps4Rails.clusterizegmaps4rails.js :353
Gmaps4Rails.create_markers
incompatibility ?
I've done everything like in how-to, and every time I try to register new user, i get the following error:
undefined method `gmaps' for #User:0xa3e0788
I am trying to get gmaps running with my mongoid application. I was able to display the map, but it isn't rendered correctly. See this image http://imagebin.org/165962 .
This is my model:
class Upload
include Mongoid::Document
include Mongoid::Document::Taggable
include Gmaps4rails::ActsAsGmappable
belongs_to :user
acts_as_gmappable
field :name, :type => String
field :description, :type => String
mount_uploader :file, FileUploader
field :latitude, :type => Float
field :longitude, :type => Float
field :gmaps, :type => Boolean
validates_presence_of :name
validates_presence_of :user
# snip
# ...
# see https://github.com/apneadiving/Google-Maps-for-Rails
def gmaps4rails_address
"Berlin, Germany"
end
end
The controller fills a variable @json
:
@json = Upload.all.to_gmaps4rails
And I use it like this in the view:
<%= gmaps4rails(@json) %>
I don't know how to find the cause of this rendering problem. Can I supply more information?
Is it possible To let this gem respond To custom mime types?
Thanks in advance
Hi,
I want to use multipul map on single page.
Here is.
# example.html.erb
<%= gmaps4rails(@json1) %>
<%= gmaps4rails(@json2) %>
Map can't display, all map white out ...
Please help if anyone knows the solution.
Thanks.
This gem looks great. Are you planning to add Google Places search, autocomplete, etc?
Hi folks,
I'm trying to use the Gmaps4Rails.replace_markers method in an ajaxed method - yet I'm getting
gmaps4rails.js:486 - Uncaught ReferenceError: google is not defined
Any ideas?
Error: undefined method gmaps' Error: undefined method
gmaps4rails' tags
Is there an updated tutorial?
On gmaps4rails docs we have:
def gmaps4rails_address
self.address #describe how to retrieve the address from your model
end
How do I set a custom composed address there? I've tried:
def gmaps4rails_address
self.address = (address + ', ' + city + ', ' + state + ', ' + zip)
end
And it didn't work, I have the city state zip and address field in my table.
Why doesn't it work?
has the gem now become rails 3.1 only? if so, what is the latest working version for rails 3.0.7 pls? i'm using 0.6.5 alright but going to production soon so would like to use the latest i can. thanks
If a single element is present in @JSON,the map shows fully-zoomed in, ignoring the zoom option. Works fine with 2 or more elements.
<%= gmaps({
"map_options" => { "type" => "SATELLITE", "center_longitude" => 180, "zoom" => 3, "auto_adjust" => true},
"markers" => { "data" => @json } } )
%>
Not sure if I am doing something wrong but everything works for me, except when I change the location with address on the model, it does get saved but the coordinates are not updated. I think I can fix this with an before_save function to call geocode but this seems like a bug to me. (or at least a nice new feature to add. :) )
Am I correct in thinking that there isn't a current way to handle a dataset where we already have latitude and longitude values in the table rows of the model, but we do not have an address to geocode? It would be nice if I could pass some options to acts_as_gmappable that would tell it where to find the lat and long data.
If that is the case, how interested would you be in adding a patch to support that functionality? I may work on one if it has a reasonable shot of being included.
Hi. How i can geocode my address and retrieve coordinates?
Dear sir, following your instructions i have no results. Coud you describe better the installation process? ....undefined method `to_gmaps4rail'?
hi there,
i want to geocode my location and display with google maps
view:
= gmaps({ "map_options" => { "auto_adjust" => true } })
= form_tag geocode_geo_locations_path, :method => :get, :remote => true do
= text_field_tag 'address'
= submit_tag 'search'
in my controller i have:
def geocode
@location = Gmaps4rails.geocode(params[:address])
if @location
@location_hash = @location.map { |loc| {:longitude => loc[:lng], :latitude => loc[:lat], :address => loc[:matched_address]} }.first
end
end
and in the view geocode.js.erb
Gmaps4Rails.replace_markers(<%=raw @location_hash.to_json %>);
it work so far, that i get a marker on the map, however the map doesnt get auto_adjusted .
how can i accomplish that??
Feature request: it would be nice to have some mocks/stubs for the geocoding calls to the google api for testing. Or document the call methods so that we can mock/stub them easily.
As stated in the title, this can be reproduced by putting an icon (png) in the image dir, then use either :marker_picture => "images/xxx.png" or "marker_picture => "images/xxx.png" in the erb statement, the actual map stops displaying the default icon but shows a blank at the place instead. marker_width and marker_length are working properly. Please take a look into this. Thanks very much.
I see a broken infowindow:
http://img811.imageshack.us/img811/6242/maprx.png
Also when i zoom out doesn't see the clustering.
What can I do?
Great gem!
Thanks
Is this feature there, or talked about already? I'm not the right guy to implement it.. but I would LOVE to see it :)
I might be able to chip in a donation via paypal for a few dollars if someone was on the edge or considering adding it/forking adding/etc
Troy
(love the maps..)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.