<%= javascript_include_tag ("https://maps.googleapis.com/maps/api/js?key=#{api_key}&sensor=false") %>
<script type="text/javascript">
    var <%= map_handler%> = <%= map_handler%> || {};

    jQuery(function () {
        var marker = null;
        var latlng = new google.maps.LatLng(<%= default_coordinates[0]%>, <%=default_coordinates[1] %>);

        var myOptions = {
            zoom: <%=zoom_level %>,
            center:latlng,
            mapTypeId:google.maps.MapTypeId.ROADMAP
        };

        var map = new google.maps.Map(document.getElementById("<%=map_container%>"), myOptions);
        <%= map_handler%> = map;

        marker = new google.maps.Marker({
            position:new google.maps.LatLng(<%= default_coordinates[0]%>,<%=default_coordinates[1] %>),
            map:map
        });

    });
</script>
<div class="<%= map_container_class%>" id="<%=map_container%>" style="<%= "width:#{map_width};height:#{map_height}"%>">
</div>

<%= javascript_include_tag ("https://maps.googleapis.com/maps/api/js?key=#{api_key}&sensor=false") %>
<script type="text/javascript">
    var <%= map_handler%> = <%= map_handler%> || {};
    $(document).on('pageshow', '#wrapper', function(e, data){
      jQuery(function () {
          var marker = null;
          var latlng = new google.maps.LatLng(<%= default_coordinates[0]%>, <%=default_coordinates[1] %>);

          var myOptions = {
              zoom: <%=zoom_level %>,
              center:latlng,
              mapTypeId:google.maps.MapTypeId.ROADMAP
          };

          var map = new google.maps.Map(document.getElementById("<%=map_container%>"), myOptions);
          <%= map_handler%> = map;

          marker = new google.maps.Marker({
              position:new google.maps.LatLng(<%= default_coordinates[0]%>,<%=default_coordinates[1] %>),
              map:map
          });
      });
    });
</script>
<div class="<%= map_container_class%>" id="<%=map_container%>" style="<%= "width:#{map_width};height:#{map_height}"%>">
</div>

Move gmap_rendering_function within pageshow listener.
Move gmap_rendering_function within pageshow listener.
