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>
16 <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 400px; display: none;"></div>
17 <span class="location">Latitude: <%= f.text_field :latitude, :size => 20, :id => "latitude" %> Longitude: <%= f.text_field :longitude, :size => 20, :id => "longitude" %></span>
18 <a href="javascript:openMap()" id="usemap">use map</a>
23 <td><%= submit_tag 'Save' %></td>
28 <% if @user.home_lat.nil? or @user.home_lon.nil? %>
29 <% lon = h(params['lon'] || '-0.1') %>
30 <% lat = h(params['lat'] || '51.5') %>
31 <% zoom = h(params['zoom'] || '4') %>
33 <% lon = @user.home_lon %>
34 <% lat = @user.home_lat %>
38 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
39 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
40 <%= javascript_include_tag 'map.js' %>
42 <script type="text/javascript">
47 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
48 var zoom = <%= zoom %>;
50 var map = createMap("map");
52 setMapCenter(centre, zoom);
54 map.events.register("click", map, setLocation);
57 function setLocation( e ) {
60 var lonlat = getEventPosition(e);
62 document.getElementById('latitude').value = lonlat.lat;
63 document.getElementById('longitude').value = lonlat.lon;
66 removeMarkerFromMap(marker);
69 marker = addMarkerToMap(merc, null, "Diary entry location");
73 $("map").style.display = "block";
74 $("usemap").style.display = "none";