gmaps4rails

Jumping markers on Google maps

醉酒当歌 提交于 2019-12-24 07:13:48
问题 I'm building a small site that uses Rails 4 and Gmaps4Rails gem to add a Google Map to the page. It works quite well except that the markers that are placed on the map based on their geo coded location jump around when I pan or zoom the map. What I mean with this is that the same marker ends up at a slightly different location! The markers are based on the map's boundary, i.e. I use Geokit to get the markers that are visible on the current map. This process is triggered every time the map

Gmaps4rails - longitude and latitude in database no updated. <nested form>

家住魔仙堡 提交于 2019-12-23 12:26:43
问题 I have a model place with attributes name, state, longitude, and latitude. A model travel_plan has many places. I'm using nested form gem for places in the travel plan form. My problem is that the longitude and latitude were not updated when name and state were updated. In my place.rb belongs_to :travel_plan acts_as_gmappable def gmaps4rails_address "#{name},#{state}" end def gmaps4rails_infowindow "<h4>#{name}</h4>" end 回答1: The answer lies here. These two settings are particularly relevant

How to stub gmaps4rails geocode functions in rspec tests?

爱⌒轻易说出口 提交于 2019-12-23 09:59:49
问题 I'm using gmaps4rails, and trying to develop some tests. I have a factory factory :country do sequence(:name) { |n| "Country#{n}" } end which is obviously not recognized by Google. Validation failed: Gmaps4rails address Address invalid The API calls are also taking time to run in my tests. How can I stub the API call out? I've tried adding before(:each) Country.stub(:geocode) end to the spec file but it has no effect. My model looks like this class Country < ActiveRecord::Base acts_as

How get car route between two coordinates using ruby?

*爱你&永不变心* 提交于 2019-12-23 04:22:12
问题 I'm developing rails app with google maps and car routes. I have a start and finish points for car route - two coordinates. How can I get a full car route (array of coordinates for car through streets)? Can I do it using gmaps4rails and geocoder ? Something like this: start_point = [41,2423; 45,323452] end_point = [42,2423; 42,323452] full_route = some_method_for_calculate_route( start_point, end_point ) #paint line on map from array of points paint_line( full_route ) Please help, thanks

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

*爱你&永不变心* 提交于 2019-12-23 02:41:13
问题 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

Any way to have gmaps4rails open the map in Street View?

自古美人都是妖i 提交于 2019-12-22 10:57:24
问题 I've tried changing the zoom level, but it always stays in the map mode. Couldn't find any info on the wiki either. Any help or other suggestions would be appreciated. 回答1: Ended up just using Google's Javascript API. It went something like this: pos = new google.maps.LatLng( <%= latitude %>, <%= longitude %> ); var div = document.getElementById('streetViewContainer'); var sv = new google.maps.StreetViewPanorama(div); sv.setPosition( pos ); sv.setVisible( true ); // find the heading by

Any way to have gmaps4rails open the map in Street View?

醉酒当歌 提交于 2019-12-22 10:56:00
问题 I've tried changing the zoom level, but it always stays in the map mode. Couldn't find any info on the wiki either. Any help or other suggestions would be appreciated. 回答1: Ended up just using Google's Javascript API. It went something like this: pos = new google.maps.LatLng( <%= latitude %>, <%= longitude %> ); var div = document.getElementById('streetViewContainer'); var sv = new google.maps.StreetViewPanorama(div); sv.setPosition( pos ); sv.setVisible( true ); // find the heading by

Using gmaps4rails with https/SSL

倾然丶 夕夏残阳落幕 提交于 2019-12-22 10:29:07
问题 I'm a big fan of gmaps4rails - it's made adding maps to our web app very easy. 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

Adjust Zoom Gmaps4Rails

[亡魂溺海] 提交于 2019-12-21 05:16:08
问题 I'm using the Gmaps4Rails gem and cannot figure out how to adjust the default zoom settings. In my view I have the following code: <%= gmaps({ "map_options" => {"auto_adjust" => false, "auto_zoom" => false, "zoom" => 15 }, "markers" => {"data" => @json } }) %> I know this has been asked and answered many times, but maybe I'm just not seeing something...any advice? Am i missing something completely obvious? I apologize for reposting this question. Thanks, Kevin EDIT I failed to properly

gmaps4rails shows just half of the map when iside tab. Any idea why?

别来无恙 提交于 2019-12-21 05:03:11
问题 I have been looking around but I have not found a problem like this. Gmaps4rails works great for me! The trouble is when inserted into a JQuery tab. It loads half of the map. It actually looks like is missing pictures. I can move/resize as usual. But only shows a part of the map. And the part missing is usually the left/bottom part. But the size of the empty part varies all the time. At the same time, the hand that shows the mouse cursor when hovering the map turns into arrow when hovering