gmaps4rails

Gmaps4rails : How to change appearance of marker when user clicks link in sidebar?

ぃ、小莉子 提交于 2019-12-13 04:47:50
问题 I'm trying to get this behavior with gmaps4rails : User clicks link in the sidebar, corresponding marker on the map changes image/color in order to make the selected one stand out from the others. I've tried with this code Gmaps.map.callback = function(){ var len = Gmaps.map.markers.length; for(var i = 0; i < len; i++){ marker = Gmaps.map.markers[i]; google.maps.event.addListener(marker.serviceObject, 'click', (function(i){ return function(){ console.log($(Gmaps.map.markers[i].serviceObject

Having trouble overriding bootstrap css for Google Maps API accessed through Gmaps4Rails Gem

情到浓时终转凉″ 提交于 2019-12-13 02:47:25
问题 I am following the Gmaps4Rails tutorial and trying to implement it in a bootstrap framework, but am having problems. The map won't load correctly... See here. Zooming in function does not work. I tried the workaround but it has only helped marginally. This appears to be a problem with how bootstrap is set up, or perhaps my require tree is not correct. See below for my relevant code. views/layouts/application.html.erb <!DOCTYPE html> <html> <head> <title><%= full_title(yield(:title)) %></title

Adding an event listener to the markers using gmaps4rails

隐身守侯 提交于 2019-12-12 09:27:07
问题 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? 回答1: 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

Gmaps is not defined

拈花ヽ惹草 提交于 2019-12-12 04:21:16
问题 I´m developing an website in ROR I am using gem 'gmaps4rails'. In localhost the map is showed, but when i put on a production server (DigitalOcean) gives me this error: Uncaught ReferenceError: Gmaps is not defined i have this script in my index.html.erb: <div id="map_show" ></div> </div> <script type="text/javascript"> handler = Gmaps.build('Google'); handler.buildMap({ provider: {}, internal: {id: 'map_show'}}, function(){ markers = handler.addMarkers(<%=raw @hash.to_json %>); handler

gmaps4rails repeating partials for markers

拟墨画扇 提交于 2019-12-11 17:54:10
问题 I am having difficulty with gmaps4rails infowindow. I have an app which successfully displays multiple markers using json data stored in activerecord. I created a partial to select additional info to display in the infowindow, but the same data from the first instance of PoliceAlert class is being repeated in each marker: Controller: class StaticPagesController < ApplicationController def main @police_alerts = PoliceAlert.all @police_hash = Gmaps4rails.build_markers(@police_alerts) do |police

gmaps4rails map not showing when loaded dynamically using prototype

爷,独闯天下 提交于 2019-12-11 16:12:38
问题 I have a view with 3 tabs each representing a view of the data (Table, Map, Charts). When I click on the tab it blinds up the view before if runs switch_view.js.rjs <%= link_to_remote I18n.t('biomass_configuration_menu.button.view.table'), :url =>{:controller => :biogas_calculator, :action => :switch_view, :view => "table"}, :method => :get, :loading => visual_effect(:blind_up, "biomass_configuration", :duration => 0.5, :queue => 'front'), :html => {:id => "table_view", :class => "toggle_map

zoom in to particular region in gmap4rails

柔情痞子 提交于 2019-12-11 07:57:12
问题 How to zoom in to a particular coordinates in gmaps4rails. suppose at the index page of my application i want to show addresses of all users but want that initially the map should focus on USA and with a certain zoom level Thanks in advance 回答1: After your gmaps call: <% content_for :scripts do %> <script type="text/javascript" charset="utf-8"> Gmaps.map.callback = function() { setTimeout(function() { var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(10, 0), new google.maps

How to get the id field and send to the view

旧街凉风 提交于 2019-12-11 07:56:10
问题 I'd like to know how can I get the ID field from my Model to pass in the JavaScript that I call when I click in a marker. My model: acts_as_gmappable :process_geocoding => false, :lat => "lat", :lng => "lon" My controller def index @locales_markers = Locale.all.to_gmaps4rails respond_to do |format| format.html { render :layout => false } end end My View <%= gmaps("markers" => { "data" => @locales_markers } %> <% content_for :scripts do %> <script> Gmaps4Rails.callback = function() { for (var

Rendering google map using gmaps4rails through Ajax

浪子不回头ぞ 提交于 2019-12-11 06:09:14
问题 I want to render the map only on demand(to minimize the loading time), means some link like 'Show Map' should render the map in a specified div. what should i do? 回答1: Simply use the 'to_gmaps4rails' method described here: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Methods Basically, do: <%=raw assets_hash.to_gmaps4rails(true) %> This will render only the js necessary to display your assets. So include gmaps4rails.js and .css (if necessary), and the div to host the map. 来源:

Gmaps4rails - How to call infowindow marker outside from maps

℡╲_俬逩灬. 提交于 2019-12-11 06:07:14
问题 I have used gmaps4rails before with success but this time i have a need that i cant figure out how to do it. I have my builder working and generating my map_info partials, also, i am able to open every infowindow from markers by clicking inside the map. What i need is to call the infowindow of a marker from a list. (onclick event inside a div for instance) builder inside controller @gmaps_markers = Gmaps4rails.build_markers(@partners) do |partner, marker| marker.lat partner.latitude marker