3 <%= error_messages_for 'diary_entry' %>
5 <% form_for :diary_entry do |f| %>
9 <td><%= f.text_field :title, :size => 60 %></td>
13 <td><%= f.text_area :body, :cols => 80 %></td>
18 <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 400px; display: none;"></div>
19 <span class="location">Latitude: <%= f.text_field :latitude, :size => 20, :id => "latitude" %> Longitude: <%= f.text_field :longitude, :size => 20, :id => "longitude" %></span>
20 <a href="javascript:openMap()" id="usemap">use map</a>
25 <td><%= submit_tag 'Save' %></td>
30 <% if @user.home_lat.nil? or @user.home_lon.nil? %>
31 <% lon = h(params['lon'] || '-0.1') %>
32 <% lat = h(params['lat'] || '51.5') %>
33 <% zoom = h(params['zoom'] || '4') %>
35 <% lon = @user.home_lon %>
36 <% lat = @user.home_lat %>
40 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
41 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
42 <%= javascript_include_tag 'map.js' %>
44 <script type="text/javascript">
49 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
50 var zoom = <%= zoom %>;
52 var map = createMap("map");
54 setMapCenter(centre, zoom);
56 map.events.register("click", map, setLocation);
59 function setLocation( e ) {
62 var lonlat = getEventPosition(e);
64 document.getElementById('latitude').value = lonlat.lat;
65 document.getElementById('longitude').value = lonlat.lon;
68 removeMarkerFromMap(marker);
71 marker = addMarkerToMap(lonlat, null, "Diary entry location");
75 $("map").style.display = "block";
76 $("usemap").style.display = "none";