1 <%= error_messages_for 'diary_entry' %>
3 <% form_for :diary_entry do |f| %>
7 <td><%= f.text_field :title, :size => 60 %></td>
11 <td><%= f.text_area :body, :cols => 80 %></td>
15 <td><a name="map"></a><div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 300px; display: none;"></div>
16 <span class="location">Latitude: <%= f.text_field :latitude, :size => 20, :id => "latitude" %> Longitude: <%= f.text_field :longitude, :size => 20, :id => "longitude" %></span> <a href="#map" id="usemap" onclick="document.getElementById('map').style.display = 'block'; document.getElementById('usemap').style.display = 'none';">use map</a> </td>
20 <td><%= submit_tag 'Save' %></td>
25 <% if @user.home_lat.nil? or @user.home_lon.nil? %>
26 <% lon = params['lon'] || '-0.1' %>
27 <% lat = params['lat'] || '51.5' %>
28 <% zoom = params['zoom'] || '4' %>
30 <% lon = @user.home_lon %>
31 <% lat = @user.home_lat %>
35 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
36 <%= javascript_include_tag 'map.js' %>
38 <script type="text/javascript">
43 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
44 var zoom = <%= zoom %>;
46 var map = createMap("map");
48 map.setCenter(centre, zoom);
50 map.events.register("click", map, setLocation);
53 function setLocation( e ) {
56 var merc = map.getLonLatFromViewPortPx(e.xy);
57 var lonlat = mercatorToLonLat(merc);
59 document.getElementById('latitude').value = lonlat.lat;
60 document.getElementById('longitude').value = lonlat.lon;
63 removeMarkerFromMap(marker);
66 marker = addMarkerToMap(merc, null, "Diary entry location");