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 : 400px; 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 = h(params['lon'] || '-0.1') %>
27 <% lat = h(params['lat'] || '51.5') %>
28 <% zoom = h(params['zoom'] || '4') %>
30 <% lon = @user.home_lon %>
31 <% lat = @user.home_lat %>
35 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
36 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
37 <%= javascript_include_tag 'map.js' %>
39 <script type="text/javascript">
44 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
45 var zoom = <%= zoom %>;
47 var map = createMap("map");
49 map.setCenter(centre, zoom);
51 map.events.register("click", map, setLocation);
54 function setLocation( e ) {
57 var merc = map.getLonLatFromViewPortPx(e.xy);
58 var lonlat = mercatorToLonLat(merc);
60 document.getElementById('latitude').value = lonlat.lat;
61 document.getElementById('longitude').value = lonlat.lon;
64 removeMarkerFromMap(marker);
67 marker = addMarkerToMap(merc, null, "Diary entry location");