Merged 7296:7388 from rails_port trunk.
This commit is contained in:
commit
4cc400de43
6 changed files with 145 additions and 129 deletions
|
@ -129,20 +129,54 @@ private
|
|||
type = named.attributes["info"].to_s.capitalize
|
||||
name = named.attributes["name"].to_s
|
||||
description = named.elements["description"].to_s
|
||||
|
||||
if name.empty?
|
||||
prefix = ""
|
||||
name = type
|
||||
else
|
||||
prefix = "#{type} "
|
||||
end
|
||||
|
||||
if place
|
||||
distance = format_distance(place.attributes["approxdistance"].to_i)
|
||||
direction = format_direction(place.attributes["direction"].to_i)
|
||||
placename = place.attributes["name"].to_s
|
||||
placename = format_name(place.attributes["name"].to_s)
|
||||
suffix = ", #{distance} #{direction} of #{placename}"
|
||||
|
||||
if place.attributes["rank"].to_i <= 30
|
||||
parent = nil
|
||||
parentrank = 0
|
||||
parentscore = 0
|
||||
|
||||
place.elements.each("nearestplaces/named") do |nearest|
|
||||
nearestrank = nearest.attributes["rank"].to_i
|
||||
nearestscore = nearestrank / nearest.attributes["distance"].to_f
|
||||
|
||||
if nearestrank > 30 and
|
||||
( nearestscore > parentscore or
|
||||
( nearestscore == parentscore and nearestrank > parentrank ) )
|
||||
parent = nearest
|
||||
parentrank = nearestrank
|
||||
parentscore = nearestscore
|
||||
end
|
||||
end
|
||||
|
||||
if parent
|
||||
parentname = format_name(parent.attributes["name"].to_s)
|
||||
|
||||
if place.attributes["info"].to_s == "suburb"
|
||||
suffix = "#{suffix}, #{parentname}"
|
||||
else
|
||||
parentdistance = format_distance(parent.attributes["approxdistance"].to_i)
|
||||
parentdirection = format_direction(parent.attributes["direction"].to_i)
|
||||
suffix = "#{suffix} (#{parentdistance} #{parentdirection} of #{parentname})"
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
suffix = ""
|
||||
end
|
||||
|
||||
results.push({:lat => lat, :lon => lon, :zoom => zoom,
|
||||
:prefix => prefix, :name => name, :suffix => suffix,
|
||||
:description => description})
|
||||
|
@ -245,6 +279,10 @@ private
|
|||
return "west"
|
||||
end
|
||||
|
||||
def format_name(name)
|
||||
return name.gsub(/( *\[[^\]]*\])*$/, "")
|
||||
end
|
||||
|
||||
def count_results(results)
|
||||
count = 0
|
||||
|
||||
|
|
|
@ -41,12 +41,12 @@
|
|||
var marker;
|
||||
|
||||
function init(){
|
||||
var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
|
||||
var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
|
||||
var zoom = <%= zoom %>;
|
||||
|
||||
var map = createMap("map");
|
||||
|
||||
map.setCenter(centre, zoom);
|
||||
setMapCenter(centre, zoom);
|
||||
|
||||
map.events.register("click", map, setLocation);
|
||||
}
|
||||
|
@ -54,8 +54,7 @@
|
|||
function setLocation( e ) {
|
||||
closeMapPopup();
|
||||
|
||||
var merc = map.getLonLatFromViewPortPx(e.xy);
|
||||
var lonlat = mercatorToLonLat(merc);
|
||||
var lonlat = getEventPosition(e);
|
||||
|
||||
document.getElementById('latitude').value = lonlat.lat;
|
||||
document.getElementById('longitude').value = lonlat.lon;
|
||||
|
|
|
@ -87,20 +87,18 @@ by the OpenStreetMap project and it's contributors.
|
|||
map = createMap("map");
|
||||
|
||||
<% if bbox %>
|
||||
var min = lonLatToMercator(new OpenLayers.LonLat(<%= minlon %>, <%= minlat %>));
|
||||
var max = lonLatToMercator(new OpenLayers.LonLat(<%= maxlon %>, <%= maxlat %>));
|
||||
var bbox = new OpenLayers.Bounds(min.lon, min.lat, max.lon, max.lat);
|
||||
var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
|
||||
|
||||
map.zoomToExtent(bbox);
|
||||
setMapExtent(bbox);
|
||||
<% else %>
|
||||
var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
|
||||
var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
|
||||
var zoom = <%= zoom %>;
|
||||
|
||||
<% if params['scale'] and params['scale'].length > 0 then %>
|
||||
zoom = scaleToZoom(<%= params['scale'].to_f() %>);
|
||||
<% end %>
|
||||
|
||||
map.setCenter(centre, zoom);
|
||||
setMapCenter(centre, zoom);
|
||||
<% end %>
|
||||
|
||||
<% if layers %>
|
||||
|
@ -108,7 +106,7 @@ by the OpenStreetMap project and it's contributors.
|
|||
<% end %>
|
||||
|
||||
<% if marker %>
|
||||
marker = addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
|
||||
marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
|
||||
<% end %>
|
||||
|
||||
map.events.register("zoomend", map, updateKey);
|
||||
|
@ -121,13 +119,13 @@ by the OpenStreetMap project and it's contributors.
|
|||
}
|
||||
|
||||
function getPosition() {
|
||||
return mercatorToLonLat(map.getCenter());
|
||||
return getMapCenter();
|
||||
}
|
||||
|
||||
function setPosition(lat, lon, zoom) {
|
||||
var centre = lonLatToMercator(new OpenLayers.LonLat(lon, lat));
|
||||
var centre = new OpenLayers.LonLat(lon, lat);
|
||||
|
||||
map.setCenter(centre, zoom);
|
||||
setMapCenter(centre, zoom);
|
||||
|
||||
if (marker)
|
||||
removeMarkerFromMap(marker);
|
||||
|
@ -136,7 +134,7 @@ by the OpenStreetMap project and it's contributors.
|
|||
}
|
||||
|
||||
function updateLocation() {
|
||||
var lonlat = mercatorToLonLat(map.getCenter());
|
||||
var lonlat = getMapCenter();
|
||||
var zoom = map.getZoom();
|
||||
var layers = getMapLayers();
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
var marker;
|
||||
|
||||
function init(){
|
||||
var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
|
||||
var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
|
||||
var zoom = <%= zoom %>;
|
||||
|
||||
<% if params['scale'] and params['scale'].length > 0 then %>
|
||||
|
@ -42,10 +42,10 @@
|
|||
|
||||
var map = createMap("map");
|
||||
|
||||
map.setCenter(centre, zoom);
|
||||
setMapCenter(centre, zoom);
|
||||
|
||||
<% if marker %>
|
||||
marker = addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)), null, "Your location");
|
||||
marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>), null, "Your location");
|
||||
<% end %>
|
||||
|
||||
var near_icon = OpenLayers.Marker.defaultIcon();
|
||||
|
@ -53,7 +53,7 @@
|
|||
var i = nearest.length;
|
||||
while( i-- ) {
|
||||
var description = 'Nearby mapper: <a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a>'
|
||||
var nearmarker = addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(nearest[i].home_lon, nearest[i].home_lat)), near_icon.clone(), description);
|
||||
var nearmarker = addMarkerToMap(new OpenLayers.LonLat(nearest[i].home_lon, nearest[i].home_lat), near_icon.clone(), description);
|
||||
}
|
||||
|
||||
map.events.register("click", map, setHome);
|
||||
|
@ -63,8 +63,7 @@
|
|||
closeMapPopup();
|
||||
|
||||
if (document.getElementById('updatehome').checked) {
|
||||
var merc = map.getLonLatFromViewPortPx(e.xy);
|
||||
var lonlat = mercatorToLonLat(merc);
|
||||
var lonlat = getEventPosition(e);
|
||||
|
||||
document.getElementById('homerow').className = '';
|
||||
document.getElementById('home_lat').value = lonlat.lat;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue