apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Maximum call stack size exceeded? #121

Closed solars closed 12 years ago

solars commented 12 years ago

Hey, I've got the following setup, what I want to do is update the markers when a map is moved:

https://gist.github.com/277894809fe04cbc29c7

The json endpoint returns for example:

[{"_id":"4ecc19ca8de17b2f0f000001","latitude":47.413358,"location":[47.413358,9.744583],"longitude":9.744583,"name":"d2"},{"_id":"4ecc14e68de17b2924000001","latitude":47.413417,"location":[47.413417,9.744417],"longitude":9.744417,"name":"another"}]

but I get the following error when moving the map:

Uncaught RangeError: Maximum call stack size exceeded I.get a.(anonymous function) tB.(anonymous function).zoomRange_changed mf I.set (anonymous function) tB.(anonymous function).zoomRange_changed mf I.set ......

No idea what causes this, I put together the sample from various sources, had to adapt a lot as it seems the methods etc changed a lot. Not sure if I missed something, I would be glad if someone could give me a pointer

Thanks a lot, Christoph

solars commented 12 years ago

anyone got an idea? I'm stuck :(

apneadiving commented 12 years ago

Answered here: http://stackoverflow.com/questions/8301097/gmaps4rails-maximum-call-stack-size-exceeded/8423759

anbublacky commented 11 years ago

This is the code i have

           <% @notice_event_place_maps = plac.to_gmaps4rails %>
            <%= @notice_event_place_maps.to_s %>
            <%= gmaps({"map_options" => {"auto_adjust" => false, "zoom" => 15 }, "markers" => {"data" => @notice_event_place_maps}}) %>

I have these fields in notice_event place:

country address1 address2 city county latitude longitude

This is the full code in my page, for one map it doesn't show error, for three maps it shows error

      <% @orbituarysite.notice_displays.each do |f| %>
          <% f.notice_event_places.each do |plac| %>
          <h6> <%= plac.event_type %></h6>
          <% if plac.eventdate? %>
          <span class="events">
          <span class="eventtitle"> திகதி:</span> <span class="eventaction"><%= plac.eventdate %>
               <%= plac.eventtime %></span>
          <span class="eventtitle">  இடம்: </span> <span class="eventaction">
            <%= plac.country %>
            <%= plac.address1 %>
            <%= plac.address2 %>
            <%= plac.city %>
            <%= plac.county %>
            <% plac.latitude %>
            <% plac.longitude %></span>
          </span>
            <%# render 'notice_event_places/maps' %>
            <%     @notice_event_place_maps = plac.to_gmaps4rails %>
            <%= @notice_event_place_maps.to_s %>
            <%# gmaps4rails(@notice_event_place_maps) %>
            <%= gmaps({"map_options" => {"auto_adjust" => false, "zoom" => 15 }, "markers" => {"data" => @notice_event_place_maps}}) %>
            <% end %>
            <%# @notice_event_place_maps = f.to_gmaps4rails %>
            <%# plac.to_gmaps4rails %>
          <% end %>
        <% end %>

I am getting the following error:

Uncaught RangeError: Maximum call stack size exceeded Gmaps.triggerOldOnload window.onload Gmaps.triggerOldOnload window.onload Gmaps.triggerOldOnload window.onload Gmaps.triggerOldOnload window.onload Gmaps.triggerOldOnload window.onload

Please tell me where am i doing mistake

apneadiving commented 11 years ago

if you have several maps on the same page, you must pass additional args: :last_map => false

anbublacky commented 11 years ago

Hi apneadiving,

:last_map => false this has solved the javascript error, now i don see any javascript error

But still my maps are not loading on the page

apneadiving commented 11 years ago

Did you put :last_map => false in all your calls? If so it's not ok.

anbublacky commented 11 years ago

Hi apneadiving,

i call gmaps in a loop so i have to add only one time

this is how i added :last_map => false

      <% @orbituarysite.notice_displays.each do |f| %>
          <% f.notice_event_places.each do |plac| %>
             ......................
            <%= gmaps({"map_options" => {"auto_adjust" => false, "zoom" => 15, "center_latitude" => plac.latitude, "center_longitude" => plac.longitude  }, "markers" => {"data" => @notice_event_place_maps}, :last_map => false}) %>
                <% end %>
               <% end %>

Also :last_map => false doesn't show single map also(if i have only one item in loop), only error cleared is in browser console error

      Uncaught RangeError: Maximum call stack size exceeded

But this doesn't help in showing the map

apneadiving commented 11 years ago

seems you do not understand:

last_map: false is to tell you're not displaying the last map.

once you reach the last_map, either skip this param or et it to true.

anbublacky commented 11 years ago

Hi

I use gmaps4rails version 1.5.6

I followed: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/%28Multiple%29-Maps

I have manually tried the above work like:

            <% a = NoticeEventPlace.where(:notice_display_id => f.id)%>
            <%= b = a.first %>
            <%= c = a.second %>
            <%= @notice_event_place_maps = b.to_gmaps4rails %>
            <%= gmaps({"map_options" => {"id" => "first_map","auto_adjust" => false, "zoom" => 15, "center_latitude" => b.latitude, "center_longitude" => b.longitude  }, "markers" => { "data" => @notice_event_place_maps, :last_map => false}}) %>
            <%= @notice_event_place_maps1 = c.to_gmaps4rails %>
            <%= gmaps({"map_options" => {"container_id" => "second_container", "id" => "second_map", "auto_adjust" => false, "zoom" => 15, "center_latitude" => c.latitude, "center_longitude" => c.longitude  }, "markers" => { "data" => @notice_event_place_maps1 }, :scripts => :none }) %>
            <div id="second_container"> 
              <div id="second_map"></div>
            </div>

Still i'm unable to see my maps, If i comment second map i can see my first map This is the error i still get:

Uncaught RangeError: Maximum call stack size exceeded

Please tell me where am i making the mistake

frankvielma commented 11 years ago

Hi anbublacky

I had a similar error and I see in your code that you have the :last_map => false into the "markers". So, Maybe it could work:

= gmaps({"map_options" => {"id" => "first_map","auto_adjust" => false, "zoom" => 15, "center_latitude" => b.latitude, "center_longitude" => b.longitude }, "markers" => { "data" => @notice_event_place_maps}, :last_map => false})

anbublacky commented 11 years ago

Hi frankvielma,

I was unable to solve the issue, so i started using leaflet rails https://github.com/axyjo/leaflet-rails, for producing multiple maps on a same page.

adambarthelson commented 10 years ago

Note, I also ran into this error after accidentally passing in nil values for marker.lat and marker.lng. Just incase anyone else is googling this error.

apneadiving commented 10 years ago

@anbublacky cant tell why you had this issue, anyway since v2, it's very easy to have independant and customizable maps.

apneadiving commented 10 years ago

I will add examples but its a first draft: http://apneadiving.github.io/