Skip to content

Commit

Permalink
BingMaps, newValueContent
Browse files Browse the repository at this point in the history
Added BingMaps Aerial to top bar, added hmdb and gb:hs to newValueContent function
  • Loading branch information
kmpoppe committed Jul 18, 2023
1 parent aee845c commit b085de5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Once you have the Greasemonkey AddOn in your browser, simply use [this](https://

## Primary Navigation Header

* Links to Mapillary and Kartaview at the map location and zoom level.
* Links to Mapillary, Kartaview and BingMaps Aerial Layer at the map location and zoom level.
* Links to OSM Community and OSM Wiki

![grafik](https://github.com/OSM-de/osm-org-greasemonkey/assets/24451207/57c3bf80-8e5c-41a4-8731-dd01b0517b71)
Expand All @@ -41,13 +41,14 @@ Once you have the Greasemonkey AddOn in your browser, simply use [this](https://
![grafik](https://github.com/OSM-de/osm-org-greasemonkey/assets/24451207/60ab1cb1-1098-4b6d-b737-79db781818ef)

* Linkifies values that point to external websites that aren't provided by osm-website for these tags:
* HE_ref and ref:GB:nhle
* openplaques:id
* mapillary
* `HE_ref` and `ref:GB:nhle` (Historic England)
* `ref:hmdb` (Historical Markers Database)
* `ref:GB:hs` (Historic Environment Scotland)
* `openplaques:id` (OpenPlaques)
* `mapillary` (Mapillary)

![grafik](https://github.com/OSM-de/osm-org-greasemonkey/assets/24451207/3d01725d-cfaa-43f7-a2d3-7327b2fbee30)


## "My Notes" page on your profile

* Button to reduce the list to only show unresolved Notes
27 changes: 21 additions & 6 deletions osm-org-greasemonkey.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Additional Links for the openstreetmap.org-sidebar
// @description This script adds links to OSM Deep History for Nodes, Ways and Relations, OSMCha for Changesets as well as KartaView and Mapillary in the primary navigation when displayed on openstreetmap.org.
// @version 23
// @version 24
// @grant none
// @copyright 2021-2023, https://github.com/joshinils and https://github.com/kmpoppe
// @license MIT
Expand Down Expand Up @@ -257,18 +257,21 @@ function modifyContent() {
// KartaView
thisUrl = "https://kartaview.org/map/@" + OsmMap.lat + "," + OsmMap.lon + "," + OsmMap.zoom + "z";
createOrUpdate("GM-KARTA", navbar_content, thisUrl, "<strong style=\"color:#0C1D2E\">Karta</strong><span style=\"color:#635BFF\">View</span>", "btn btn-outline-primary");
// Bing Aerial
thisUrl = "https://www.bing.com/maps?cp=" + OsmMap.lat + "%7E" + OsmMap.lon + "&lvl=" + (parseInt(OsmMap.zoom)+1).toString() + "&style=a";
createOrUpdate("GM-BING", navbar_content, thisUrl, "BingMaps", "btn btn-outline-primary", "BingMaps Aerial Layer");
// Discourse Community
thisUrl = "https://community.openstreetmap.org/";
createOrUpdate("GM-COMMU", navbar_content, thisUrl, "<span style=\"color:\">OSM</span> <strong style=\"color:\">Community</strong>", "btn btn-outline-primary");
createOrUpdate("GM-COMMU", navbar_content, thisUrl, "<span style=\"color:\">OSM</span> <strong style=\"color:\">Community</strong>", "btn btn-outline-primary", "OpenStreetMap Community Discourse");
// Wiki
thisUrl = "https://wiki.openstreetmap.org/wiki/Main_Page";
createOrUpdate("GM-WIKIP", navbar_content, thisUrl, "<span style=\"color:\">OSM</span> <strong style=\"color:\">Wiki</strong>", "btn btn-outline-primary");
createOrUpdate("GM-WIKIP", navbar_content, thisUrl, "<span style=\"color:\">OSM</span> <strong style=\"color:\">Wiki</strong>", "btn btn-outline-primary", "OpenStreetMap Wiki Main Page");
}
}
}

// Create, Update and DOM Elements general
function createOrUpdate(id, targetObject, thisUrl, text, className = "") {
function createOrUpdate(id, targetObject, thisUrl, text, className = "", title = "") {
var existingAnchor = document.getElementById(id);
if (existingAnchor) {
existingAnchor.href = thisUrl;
Expand All @@ -278,18 +281,20 @@ function createOrUpdate(id, targetObject, thisUrl, text, className = "") {
id,
thisUrl,
text,
className
className,
title
)
);
}
}

function getAnchorElement(id, url, text, className = "", target = "_blank") {
function getAnchorElement(id, url, text, className = "", title = "", target = "_blank") {
var anchor;
anchor = document.createElement("a");
anchor.id = id;
anchor.target = target;
anchor.href = url;
anchor.title = title;
anchor.innerHTML = "<center>" + text + "</center>";
if (className !== "") {
anchor.className = className;
Expand Down Expand Up @@ -502,6 +507,16 @@ function returnNewValueContent(key, value) {
url = "https://www.mapillary.com/app/?focus=photo&pKey=" + value;
title = "Mapillary";
}
// Historical Markers Database
if (key === "ref:hmdb") {
url = "https://www.hmdb.org/m.asp?m=" + value;
title = "Historical Markers Database";
}
// Historic Environment Scotland
if (key == "ref:gb:hs") {
url = "https://portal.historicenvironment.scot/designation/" + value;
title = "Historic Environment Scotland"
}
if (url != "" && title != "") {
returnValue = "<a href=\"" + url + "\" target=\"_blank\" title=\"" + title + " [Added by GreaseMonkey]\">" + value + "</a>";
url = "";
Expand Down

0 comments on commit b085de5

Please sign in to comment.