$(document).ready(function () {
- var params = $("#map").data();
var map = createMap("map");
- setMapCenter(new OpenLayers.LonLat(params.lon, params.lat), params.zoom);
+ if (OSM.home) {
+ setMapCenter(new OpenLayers.LonLat(OSM.home.lon, OSM.home.lat), 12);
+ } else {
+ setMapCenter(new OpenLayers.LonLat(0, 0), 0);
+ }
if ($("#map").hasClass("set_location")) {
var marker;
- if (params.marker) {
- marker = addMarkerToMap(new OpenLayers.LonLat(params.lon, params.lat));
+ if (OSM.home) {
+ marker = addMarkerToMap(new OpenLayers.LonLat(OSM.home.lon, OSM.home.lat));
}
map.events.register("click", map, function (e) {
}
});
} else {
- addMarkerToMap(new OpenLayers.LonLat(params.lon, params.lat), null, params.marker.description);
-
$("[data-user]").each(function () {
var user = $(this).data('user');
if (user.lon && user.lat) {
<% content_for :head do %>
<%= javascript_include_tag "user" %>
<% end %>
- <%
- home = @user.home_lat && @user.home_lon
- data = {
- :lon => @user.home_lon || 0,
- :lat => @user.home_lat || 20,
- :zoom => home ? 12 : 1,
- :marker => !!home
- }
- %>
- <%= content_tag "div", "", :id => "map", :class => "user_map set_location", :data => data %>
+ <%= content_tag "div", "", :id => "map", :class => "user_map set_location" %>
</td>
</tr>
<%= javascript_include_tag "user" %>
<% end %>
<%
- data = {
+ user_data = {
:lon => @user.home_lon,
:lat => @user.home_lat,
- :zoom => 12,
- :marker => {
- :description => render(:partial => "popup", :object => @user, :locals => {:type => "your location"})
- }
+ :icon => "marker.png",
+ :description => render(:partial => "popup", :object => @user, :locals => {:type => "your location"})
}
%>
- <%= content_tag "div", "", :id => "map", :class => "user_map", :data => data %>
+ <%= content_tag "div", "", :id => "map", :class => "user_map", :data => {:user => user_data} %>
<% end %>
<% friends = @this_user.friends.collect { |f| f.befriendee } %>