dimanche 30 août 2015

Ruby on Rails: Gmaps4Rails: adding values to @Hash passed from Gmaps4rails.build_markers

I'm new to Ruby on Rails. I'm developing a small Maps Application using gmaps4rails and geocoding gems. My repository is http://ift.tt/1N3lfv6

Right now I'm loading the map with the normal code:

  <div style='width: 800px;'>
              <div id="map" style='width: 800px; height: 400px;'></div>
            </div>

  <script type="text/javascript">
    handler = Gmaps.build('Google');
    handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
    markers = handler.addMarkers(<%=raw @hash.to_json %>);
    handler.bounds.extendWith(markers);
    handler.fitMapToBounds();
    });
  </script>

I want to know a way of adding another Point in the map after the DB is loaded in the map. My goal is to Load the DB in the map (already working), then load another point (where the user is) in the same map. For example.. Why doesn't this work?

  <script type="text/javascript">
    handler = Gmaps.build('Google');
    handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
    markers = handler.addMarkers([{<%=raw @hash.to_json %>},{ lat: 43, lng: 3.5}]);
    handler.bounds.extendWith(markers);
    handler.fitMapToBounds();
    });
  </script>

thank you

Aucun commentaire:

Enregistrer un commentaire