Add a permalink that opens the relevant view in OSM.org in a different window

This commit is contained in:
Schuyler Erle 2012-02-22 06:27:36 -08:00
parent 374a8f695f
commit 67a65eec98

View File

@ -233,7 +233,8 @@ var API_BASE = "/1.0/",
function initMap() {
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
map = new OpenLayers.Map("mapCol", {
projection: new OpenLayers.Projection("EPSG:900913")
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
});
var layers = [];
// layers[0] = new OpenLayers.Layer.OSM();
@ -245,9 +246,15 @@ var API_BASE = "/1.0/",
key: "AqGpO7N9ioFw3YHoPV3C8crGfJqW5YST4gGKgIOnijrUbitLlgcAS2A0M9SJrUv9",
});
geojson_format = new OpenLayers.Format.GeoJSON();
//
//yes, jsonLayer is global. Yes, I know it's wrong.
jsonLayer = layers[2] = new OpenLayers.Layer.Vector("Bus Stops");
map.addLayers(layers);
jsonLayer.events.on({
'featureselected': onFeatureSelect,
'featureunselected': onFeatureUnselect
});
map.setCenter(center, 12);
var navigationControl = new OpenLayers.Control.Navigation({
defaultDblClick: function(event) {
@ -274,28 +281,30 @@ var API_BASE = "/1.0/",
var pt = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
var feature = new OpenLayers.Feature.Vector(pt, stop);
$('.selectedStop').removeClass("no_has_point").addClass("has_point");
//console.log("trying to add", feature);
jsonLayer.addFeatures([feature]);
mapControl.select(feature);
}
// console.log(lonlat);
return;
}
});
map.addControl(navigationControl);
// Feature selection control
mapControl = new OpenLayers.Control.SelectFeature(jsonLayer, {
clickout: false,
toggle: true
});
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(mapControl);
// map.addControl(zoomControl);
mapControl.activate();
// zoomControl.activate();
jsonLayer.events.on({
'featureselected': onFeatureSelect,
'featureunselected': onFeatureUnselect
});
// Add a LayerSwitcher since we now have Bing
map.addControl(new OpenLayers.Control.LayerSwitcher());
// Add a permalink that opens the relevant view in OSM.org in a different window
var permalink = new OpenLayers.Control.Permalink({base: "http://www.openstreetmap.org/"});
map.addControl(permalink);
$(".olControlPermalink a").attr("target","_blank").html("View in OSM");
}
function onFeatureSelect(e) {