javascript - Google Maps V3 - json marker loading issue (using Rails 3.1 for data) -


We are building a Google Map app in Rail, which initially created a JavaScript JSX marker generating function By using the .to_json method on the data object).

Then we have a listener on the zoom action which takes the new Jason file directly and feeds it on the same marker function.

On initial load markers are rotate right, but no new zoom appears. While examining the rail logs, the JSN file is being called, so the problem is how Jason Data is processed, or how the marker is distributed.

Can any of you see the problem?

  var map; Function initialize () {var myOptions = {zoom: & lt;% = @ zoom% & gt ;, center: new google.maps.LatLng (& lt;% = @ center% & gt;), type the map: google .maps.MapTypeId.ROADMAP}; Map = new google.maps.map (document.getElementById ('map_canvas'), myOptions); Stream_json = (& lt;% = raw (@ stream.to_json)%>); Parse_json (stream_json); Google.maps.event.addListener (map, 'zoom_chard', function () {json_url = "/ test? Bounds =" + map.getBounds () + "& zoom =" + map.getZoom (); stream_json = $ .getJSON (json_url); parse_json (stream_json);}); Function parse_json (json) {if (json.length & gt; 0) {var marker = []; (I = 0; i & lt; json.length; i ++) for {var location = JSN [i]; Warning (location.lumb ++, '+ place.latitude); // Add location (location); Marker [i] = New google.maps.Marker ({Map: Map, Status: New google.maps.LatLng (place.latitude, place.longitude)}); }}}; } Google.maps.event.addDomListener (window, 'load', start);   

Many thanks in advance for any indication, you can send your way!

You are not using it correctly, this is an inelegant call, so to supply callback Required:

  google.maps.event.addListener (map, 'zoom_chat', function () {json_url = "/ test? Bounds =" + Map.getBounds () + "& Amp; zoom = "+ map.getZoom (); $ .getJSON (json_url, function) {parse_json (data);}}}});    

Comments