gmaps4rails

Gmaps4rails : map not showing when loaded dynamically

别说谁变了你拦得住时间么 提交于 2019-12-11 05:08:31
问题 When I display a map using Gmaps4rails through a Jquery call ( $('#id').load(/xyz) ), the map is not shown (a blank area is shown instead). This page : https://groups.google.com/group/Google-Maps-API/browse_thread/thread/02710b15f3d76ec2/67413d33e7fd0e74?hl=en suggests calling map.reloadMap once the page has been loaded, however I don't know the id of the element that should be called. The gmaps4rails documentation only mentions the id of the div containing the map and reading the source didn

gmaps4rails callback not firing

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 05:03:24
问题 = gmaps(markers: { data: @json, options: @marker_options }, map_options: @map_options ) - content_for :map_scripts do :javascript Gmaps.map.callback = function() { alert('asdf') // <-- I never see this alert } Using the gmaps4rails gem (v1.5.2), I placed the code above in my view. My map appears fine with my markers. But with my javascript, shouldn't I get an alert (I'm not)? I'm not sure if I understand the callback completely. FYI, the javascript appears fine in my source. 回答1: It should be

gmaps4rails replaceMakers flicker effect

你。 提交于 2019-12-11 02:57:39
问题 When user pans the map, I make and ajax request to the server and get all the markers that fall into the new bounds, something almost identical to what is described here: Dynamically load Google Maps Markers with gmaps4rails My problem is that when I use replaceMarker all the markers on the map are recreated therefore each of them flickers onces. This really annoys me. If I use addMarkers, I don't get the flicker effect, but my sidebar gets screwed because; 1) The markers which are left out

gmaps4rails zoom on one marker

ぐ巨炮叔叔 提交于 2019-12-11 01:04:39
问题 I'm using gmaps4rails, and I'd like to keep using the auto zoom feature, but in case I only have one marker I'd like to change the zoom, cause the default one is the maximum zoom. Having read the related question I added this code to my javascript file: $(function() { //to address the problem with the zoom being set to maximum when there's only one marker Gmaps.map.callback = function() { console.log("in callback"); if (Gmaps.map.markers.length == 1) { console.log("only one marker"); //only

Polygon infowindows in Gmaps4Rails

淺唱寂寞╮ 提交于 2019-12-11 00:56:08
问题 I'm using gmap4rails to draw a bunch of fairly complicated polygons that serve as district boundaries. I've got two things i would like help with: Firstly, I want to associate an info window on click with these polygons. This is an example of my use-case: https://google-developers.appspot.com/maps/documentation/javascript/examples/polygon-arrays I've tried registering a click event handler in the gmap's callback but it doesn't work and I don't think it's the right approach. Gmaps.map.callback

gmaps4rails and autocomplete google place API incompatibility

拈花ヽ惹草 提交于 2019-12-11 00:03:46
问题 I've a problem of compatibility between gmaps4rails gem and google place API Basically if I put in my view a gmpas4rails like this: <%=gmaps%> then this script doesnt work anymore (it normaly activate an autocomplete on user_address field: $(document).ready(initialize_gmaps_autocomplete_user_address()); function initialize_gmaps_autocomplete_user_address() { var input = document.getElementById('user_address'); var defaultBounds = new google.maps.LatLngBounds(new google.maps.LatLng(42.71422,-4

gmaps4rails disable scroll wheel

懵懂的女人 提交于 2019-12-10 12:09:13
问题 I'm using gmaps4rails like so: <%= gmaps("map_options" => { "scrollwheel" => false, "zoom" => 17, "auto_zoom" => false },"markers" => { "data" => event.to_gmaps4rails }) %> This is generating: <script type="text/javascript" charset="utf-8"> Gmaps.map = new Gmaps4RailsGoogle(); Gmaps.load_map = function() { Gmaps.map.map_options.scrollwheel = false; Gmaps.map.map_options.zoom = 17; Gmaps.map.map_options.auto_zoom = false; Gmaps.map.initialize(); Gmaps.map.markers = [{"lat":38.6419,"lng":-90

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-10 10:08:03
问题 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 ==

Google Maps: scroll map programmatically of x pixels

走远了吗. 提交于 2019-12-09 04:39:31
问题 Is there a simple way to scroll a google map programmatically of x pixels? I can only think of using setCenter , but the problem is that I would have to compute the new location (lat/lng) depending on the zoom level... Can you think of something else? Telling me that it's not possible with the Google Map API is a valid answer if you're pretty sure about it. ps: I'm using Gmaps4rails, so if you can think of a way to do that with the gem, it'd be cool. (like adjusting the bounds to a subset of

how to set a zoom level using Gmap4rails?

不打扰是莪最后的温柔 提交于 2019-12-08 23:32:39
I've just setup a new project following this video http://youtu.be/R0l-7en3dUw . I was wondering how can I set the map zoom level in a project like this. I've looked at the src on github and since in map.coffee there isn't something like zoomTo: (zoomLvl)-> @getServiceObject().setZoom(zoomLvl) I don't have any idea how to do it. So can anyone help me? I've tried this kind of solution as suggested here ( zoom in to particular region in gmap4rails ) but with any good result: Gmaps.map.callback = function() { google.maps.event.addListenerOnce(Gmaps.map.getMapObject(), 'idle', function(){ var