Add a permalink that opens the relevant view in OSM.org in a different window
This commit is contained in:
parent
374a8f695f
commit
67a65eec98
|
@ -233,7 +233,8 @@ var API_BASE = "/1.0/",
|
||||||
function initMap() {
|
function initMap() {
|
||||||
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
|
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
|
||||||
map = new OpenLayers.Map("mapCol", {
|
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 = [];
|
var layers = [];
|
||||||
// layers[0] = new OpenLayers.Layer.OSM();
|
// layers[0] = new OpenLayers.Layer.OSM();
|
||||||
|
@ -245,9 +246,15 @@ var API_BASE = "/1.0/",
|
||||||
key: "AqGpO7N9ioFw3YHoPV3C8crGfJqW5YST4gGKgIOnijrUbitLlgcAS2A0M9SJrUv9",
|
key: "AqGpO7N9ioFw3YHoPV3C8crGfJqW5YST4gGKgIOnijrUbitLlgcAS2A0M9SJrUv9",
|
||||||
});
|
});
|
||||||
geojson_format = new OpenLayers.Format.GeoJSON();
|
geojson_format = new OpenLayers.Format.GeoJSON();
|
||||||
|
//
|
||||||
//yes, jsonLayer is global. Yes, I know it's wrong.
|
//yes, jsonLayer is global. Yes, I know it's wrong.
|
||||||
jsonLayer = layers[2] = new OpenLayers.Layer.Vector("Bus Stops");
|
jsonLayer = layers[2] = new OpenLayers.Layer.Vector("Bus Stops");
|
||||||
map.addLayers(layers);
|
map.addLayers(layers);
|
||||||
|
jsonLayer.events.on({
|
||||||
|
'featureselected': onFeatureSelect,
|
||||||
|
'featureunselected': onFeatureUnselect
|
||||||
|
});
|
||||||
|
|
||||||
map.setCenter(center, 12);
|
map.setCenter(center, 12);
|
||||||
var navigationControl = new OpenLayers.Control.Navigation({
|
var navigationControl = new OpenLayers.Control.Navigation({
|
||||||
defaultDblClick: function(event) {
|
defaultDblClick: function(event) {
|
||||||
|
@ -274,28 +281,30 @@ var API_BASE = "/1.0/",
|
||||||
var pt = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
|
var pt = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
|
||||||
var feature = new OpenLayers.Feature.Vector(pt, stop);
|
var feature = new OpenLayers.Feature.Vector(pt, stop);
|
||||||
$('.selectedStop').removeClass("no_has_point").addClass("has_point");
|
$('.selectedStop').removeClass("no_has_point").addClass("has_point");
|
||||||
//console.log("trying to add", feature);
|
|
||||||
jsonLayer.addFeatures([feature]);
|
jsonLayer.addFeatures([feature]);
|
||||||
mapControl.select(feature);
|
mapControl.select(feature);
|
||||||
}
|
}
|
||||||
// console.log(lonlat);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
map.addControl(navigationControl);
|
map.addControl(navigationControl);
|
||||||
|
|
||||||
|
// Feature selection control
|
||||||
mapControl = new OpenLayers.Control.SelectFeature(jsonLayer, {
|
mapControl = new OpenLayers.Control.SelectFeature(jsonLayer, {
|
||||||
clickout: false,
|
clickout: false,
|
||||||
toggle: true
|
toggle: true
|
||||||
});
|
});
|
||||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
|
||||||
map.addControl(mapControl);
|
map.addControl(mapControl);
|
||||||
// map.addControl(zoomControl);
|
|
||||||
mapControl.activate();
|
mapControl.activate();
|
||||||
// zoomControl.activate();
|
|
||||||
jsonLayer.events.on({
|
// Add a LayerSwitcher since we now have Bing
|
||||||
'featureselected': onFeatureSelect,
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
'featureunselected': onFeatureUnselect
|
|
||||||
});
|
// 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) {
|
function onFeatureSelect(e) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user