source: subversion/sites/rails_port/app/views/diary_entry/new.rhtml @ 7384

Revision 7384, 2.0 KB checked in by tomhughes, 6 years ago (diff)

Get rid of our reprojection code and use OpenLayers? reprojection instead.

Line 
1<%= error_messages_for 'diary_entry' %>
2
3<% form_for :diary_entry do |f| %>
4  <table>
5    <tr valign="top">
6      <th>Subject</th>
7      <td><%= f.text_field :title, :size => 60 %></td>
8    </tr>
9    <tr valign="top">
10      <th>Body</th>
11      <td><%= f.text_area :body, :cols => 80 %></td>
12    </tr>
13    <tr valign="top">
14            <th>Location</th>
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>
17          </tr>
18    <tr>
19      <th></th>
20      <td><%= submit_tag 'Save' %></td>
21    </tr>
22  </table>
23<% end %>
24
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') %>
29<% else %>
30  <% lon = @user.home_lon %>
31  <% lat = @user.home_lat %>
32  <% zoom = '12' %>
33<% end %>
34
35<%= javascript_include_tag '/openlayers/OpenLayers.js' %>
36<%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
37<%= javascript_include_tag 'map.js' %>
38
39<script type="text/javascript">
40  <!--
41  var marker;
42
43  function init(){
44    var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
45    var zoom = <%= zoom %>;
46
47    var map = createMap("map");
48
49    setMapCenter(centre, zoom);
50
51    map.events.register("click", map, setLocation);
52  }       
53
54  function setLocation( e ) {
55    closeMapPopup();
56
57    var lonlat = getEventPosition(e);
58
59    document.getElementById('latitude').value = lonlat.lat;
60    document.getElementById('longitude').value = lonlat.lon;
61
62    if (marker) {
63      removeMarkerFromMap(marker);
64    }
65
66    marker = addMarkerToMap(merc, null, "Diary entry location");
67  }
68
69  window.onload = init;
70// -->
71</script>
Note: See TracBrowser for help on using the repository browser.