gmaps4rails

Google Maps For Rails - updating markers via ajax only when search result changes

烈酒焚心 提交于 2019-12-08 02:28:25
I have been working through writing a small app with a lot of help from stackoverflow. The basic premise is simple, and I've seen this sort of functionality all over the web: I am trying to plot a list of locations onto a searchable/pannable google map. The locations are stored on the backend, and the controller feeds these locations to the view. AJAX is involved because I don't want to reload the entire page. Here are the scenarios: a) User searches for a location via zipcode => map loads new location, a search get is sent to server and map loads any markers if there are any within set radius

gmaps4rails get latitude and longitude in the server

≡放荡痞女 提交于 2019-12-07 15:27:24
I'm reading about 'gmaps4rails' , but I have a question about the gem. Is possible obtain the location (lat, lng) only with the address? Yes it is, but I would first use the Geocoder gem. gem 'geocoder' You need to create a migration to add latitude and longitude floats to your table rails g migration AddLatitudeAndLongitueToModel latitude:float longitude:float Obviously, replace Model with your table name. then run rake db:migrate Then in your model, make sure the attribute for an address is being geocoded geocoded_by :location # replace location with the attribute of the address I would also

Accessing json attributes from marker - gmaps4rails

两盒软妹~` 提交于 2019-12-07 14:42:45
问题 I'm upgrading to gmaps4rails v2. I can't seem to access the marker json attributes from javascript. This worked in the previous version I was using (1.5.6) Specifically Buidling in controller: @users = User.all @hash = Gmaps4rails.build_markers(@users) do |user, marker| marker.lat user.latitude marker.lng user.longitude marker.json({link: "someurl", current: true}) end And in javascript: handler = Gmaps.build('Google'); handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){

gmaps4rails on jQueryMobile don't work

社会主义新天地 提交于 2019-12-06 16:39:02
I tried gmaps4rails on jQueryMobile Framework. One page is only link to gmaps page. Two page is gmaps4rails page. jQueryMobile ajax page enabled. From one page to two page don't display gmaps. But Two page direct access is success display gmaps. This is my repository. https://github.com/y-hirasawa/sample-jqm-map I want to use ajax pages, and display gmaps. Help me. You need to include the googlemaps javascript files in your layout: <script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.5&sensor=false&libraries=geometry"></script> <script type="text/javascript" src="http:/

Rails 5, Gmaps4Rails - setup

无人久伴 提交于 2019-12-06 05:22:11
问题 I have been trying for years to figure out how to incorporate gmaps4rails in a rails app. I have made an entirely new app and tried fresh. I can't figure out what's going wrong. I'm looking for setup instructions that are complete and up to date. Many SO posts refer to old versions of dependencies that end up saying that the issue is solved in a later version. Currently, I have this in my view: <script src="//maps.google.com/maps/api/js?v=3.23&key=<%= ENV['GOOGLE_MAPS_API_KEY'] %>"></script>

Gmaps4Rails : How to open the Infowindow of the single marker by default when the Google maps is loaded (without clicking on the marker)

前提是你 提交于 2019-12-06 04:18:18
I am using Gmaps4Rails in my rails application for loading google maps. Everything works fine. I have a single marker and I want to keep the infowindow open by default when the google map is loaded (without clicking on the marker). Please help me how to achieve this using Gmaps4Rails gem? I have tried the following snippet of code but it doesn't work. <% content_for :scripts do %> <script type="text/javascript" charset="utf-8"> Gmaps.map.callback = function() { if (Gmaps.map.markers.length == 1) { var marker = Gmaps.map.markers[0]; var infowindow = marker.infowindow; infowindow.open(Gmaps.map

Accessing json attributes from marker - gmaps4rails

允我心安 提交于 2019-12-06 03:41:26
I'm upgrading to gmaps4rails v2. I can't seem to access the marker json attributes from javascript. This worked in the previous version I was using (1.5.6) Specifically Buidling in controller: @users = User.all @hash = Gmaps4rails.build_markers(@users) do |user, marker| marker.lat user.latitude marker.lng user.longitude marker.json({link: "someurl", current: true}) end And in javascript: handler = Gmaps.build('Google'); handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){ markers = handler.addMarkers(<%=raw @hash.to_json %>); console.log(markers[0].link); console.log(markers[1]

Trouble displaying a custom marker using gmaps4rails

自古美人都是妖i 提交于 2019-12-05 05:58:47
问题 This gem is awesome for displaying a dynamic map. I am a beginner programmer, and I cannot seem to get a custom marker to display on the map. I have the following in my model: def gmaps4rails_marker_picture { "picture" => 'images/logo_avatar.png', "width" => '16', "height" => '16' } end I have tried many combinations of the info provided in the github README, but to no avail. My map works perfectly until the above code gets plugged into the model....then all the markers go away. Is the

Adding an event listener to the markers using gmaps4rails

99封情书 提交于 2019-12-04 20:22:26
I am developing an application that uses gmaps4rails (https://github.com/apneadiving/Google-Maps-for-Rails). I want to add an event listener to the marker so that it creates a visualization next to the map (as well as displaying an info window on the map). Is it possible to add an event listener for each marker using gmaps4rails? Of course it's possible. You should write your code in the gmaps4rails_callback javascript function to be sure it's executed when everything is setup. And then loop the markers js variable: Gmaps4Rails.markers The attributes of each marker in this array are: longitude

Make map marker direct link onclick for gmaps4rails

依然范特西╮ 提交于 2019-12-04 06:38:24
问题 Currently have the infowindow showing as the 'what happens' when the map marker is clicked, as so: google.maps.event.addListener(marker, 'click', function(){ infowindow.open(Gmaps.map.map, marker); }); How would I get this to work to automatically link to the marker's SHOW page, ie. where is it possible to put in a code reference: <a href='/controller/#{slug}'>#{title}</a> or <%= link_to %> function 回答1: For this kind of needs, I pass a block to the gmaps4rails method in the controller (doc