gmaps4rails

Gmaps4rails : Setting map width and height

好久不见. 提交于 2019-12-04 02:53:32
问题 Reading the gmaps4rails gem documentation, I didn't find any way to set the map width and height. Is there any way to do this ? 回答1: I should have given further details about this. I'll make an installation rake task to copy css and javascript in the Rails app. Well, for now, simply override this in your css (I assume you didn't change the map id). #gmaps4rails_map { width: 800px; height: 400px; } If you want it to work, beware to include your css after the yield(:head) <%= yield :head %> <%=

gmaps4rails - update dynamically the markers from the database on the map without refresh the page

自闭症网瘾萝莉.ら 提交于 2019-12-04 01:32:49
问题 Hello I building Live bus tracking Rails app. I displayed very well my markers from the database on my Google Map in Rails 4 with the gmaps4rails gem. Controller: @hash = Gmaps4rails.build_markers(@vehicle_trackings) do |track, marker| marker.lat track.latitude marker.lng track.longitude marker.picture({ url: "/images/Bus Filled-30.png", width: 50, height: 50 }) end View: <div id='map' style='width: 100%; height: 500px;'></div> <script> handler = Gmaps.build('Google'); handler.buildMap({

Adjust Zoom Gmaps4Rails

邮差的信 提交于 2019-12-03 16:21:14
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 comment out the default instance of gmaps and it overrode my customized settings. Thanks for all the help

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

一世执手 提交于 2019-12-03 15:29:21
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 this empty part(but this part is still inside the Google container). If I place the gmaps container out

Google Maps: scroll map programmatically of x pixels

时间秒杀一切 提交于 2019-12-03 03:12:52
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 the map.) Because in the end my goal is to prevent the menu from hidding some markers. I would need to

Rails 4 - how to reference a javascript source in vendor file

冷暖自知 提交于 2019-12-02 11:47:39
问题 I have just discovered that I need to amend my GMaps for Rails setup by inserting javascript files directly in my app. Rails 4 - Gmaps4Rails - map won't render I have cloned both infobox and markerclusterer repos and am now stuck in trying to reference the relevant files in my app. I have the folders of files that came with the clone in my vendor file. I understand the javascript files that I need to use are: infobox.js and markerclusterer.js These files are located in: vendor/js-marker

Slippy maps for gmaps4rails

情到浓时终转凉″ 提交于 2019-12-02 09:35:01
问题 I thought it would be nice to use OpenStreetMap (or OpenCycleMap) as a map tile provider within the google API. Here is an example of how this is done in plain javascript: <script type="text/javascript"> var element = document.getElementById("map"); /* Build list of map types. You can also use var mapTypeIds = ["roadmap", "satellite", "hybrid", "terrain", "OSM"] but static lists sucks when google updates the default list of map types. */ var mapTypeIds = []; for(var type in google.maps

Slippy maps for gmaps4rails

我只是一个虾纸丫 提交于 2019-12-02 06:50:35
I thought it would be nice to use OpenStreetMap (or OpenCycleMap) as a map tile provider within the google API. Here is an example of how this is done in plain javascript: <script type="text/javascript"> var element = document.getElementById("map"); /* Build list of map types. You can also use var mapTypeIds = ["roadmap", "satellite", "hybrid", "terrain", "OSM"] but static lists sucks when google updates the default list of map types. */ var mapTypeIds = []; for(var type in google.maps.MapTypeId) { mapTypeIds.push(google.maps.MapTypeId[type]); } mapTypeIds.push("OSM"); var map = new google

add marker with Google-Maps-for-Rails

痴心易碎 提交于 2019-12-02 06:32:57
问题 I was playing with https://github.com/apneadiving/Google-Maps-for-Rails and i'd like to clear all the marker on a map and add a new one at the position clicked by the user on the map, I added the following code in my page <script type="text/javascript" charset="utf-8"> function gmaps4rails_callback() { google.maps.event.addListener(Gmaps4Rails.map, 'click', function(object){ alert(object.latLng); }); </script> And in this way i can see an alert with the lat and long value, now how can i

How do I make an infowindow automatically display as open with Google-Maps-for-Rails

↘锁芯ラ 提交于 2019-12-02 03:05:45
问题 I want to display a map with the infowindow box automatically displayed for the single marker on the page, much like http://code.google.com/apis/maps/documentation/javascript/examples/map-coordinates.html I've tried to code a callback function to accomplish this, but it's just not working for me. <% 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