Sha256: e258e81471671351b19bd1f8ac928ce36988b4d474a4a6642f5dc7719db9c4e0

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

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

    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);
        gMapObj = map;

        <% if lat_column_value && lng_column_value%>
        marker = new google.maps.Marker({
            position:new google.maps.LatLng(<%= lat_column_value%>,<%=lng_column_value %>),
            map:map
        });
    <% end%>

        google.maps.event.addListener(map, 'click', function(e) {
            updateLocation(e.latLng);
        });

        function updateLocation(location) {
            if(marker) {
                marker.setPosition(location);
            } else {
                marker = new google.maps.Marker({
                    position: location,
                    map: map
                });
            }

            map.setCenter(location);
            jQuery("#<%= lat_dom_id%>").val(location.lat());
            jQuery("#<%=lng_dom_id %>").val(location.lng());
        }

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gmap_coordinates_picker-0.0.2 app/views/gmap_coordinate_picker/_gmap_coordinate_picker.html.erb
gmap_coordinates_picker-0.0.1 app/views/gmap_coordinate_picker/_gmap_coordinate_picker.html.erb