Skip to content

Commit

Permalink
adding to PR#9 and using built-in marker but a different color. Can a…
Browse files Browse the repository at this point in the history
…lter the icon via css .qth-icon
  • Loading branch information
stephenhouser committed Dec 23, 2024
1 parent acefb10 commit ba7e9cb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h2>Show the Map or the Log</h2>
// ex: qth=22.303940,114.170372 will place a yellow marker at 22.3, 114.1 on the map
var qth = getQueryVariable('qth');
if (qth !== null) {
createQTHMarker(qth, "Home QTH")
createQTHMarker(qth, "Home QTH")
}
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions leaflet-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function removeAllPolygons() {
* Set up a marker on the map and corresponding pop-up for when the
* marker is selected.
*/
function createMarker(latitude, longitude, popupText) {
function createMarker(latitude, longitude, popupText, options={}) {
// To use a smaller marker, use something like this...
// var blueMarkerSmall = L.icon({
// iconUrl: 'icons/blu-blank.png',
Expand All @@ -115,7 +115,7 @@ function createMarker(latitude, longitude, popupText) {
// });
//var marker = L.marker([latitude, longitude], {icon: blueMarkerSmall});

var marker = L.marker([latitude, longitude]);
var marker = L.marker([latitude, longitude], options);

marker.addTo(_markerFeatureGroup)
.bindPopup(popupText);
Expand Down
5 changes: 5 additions & 0 deletions qso-mapper.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ body {
background: white;
}

.qth-icon {
/* https://stackoverflow.com/questions/23567203/leaflet-changing-marker-color */
filter: hue-rotate(120deg);
}

.background {
padding: 3em;
position: absolute;
Expand Down
41 changes: 17 additions & 24 deletions qso-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,44 +216,37 @@ function removeQso(qso) {
*
* Set up a marker on the map for operating QTH and corresponding pop-up for
* when the marker is selected.
*
* Change the color of the marker using CSS huechange
* https://stackoverflow.com/questions/23567203/leaflet-changing-marker-color
*/
function createQTHMarker(latlong, popupText) {
// To use a smaller marker, use something like this...
var blueMarkerSmall = L.icon({
iconUrl: 'icons/ylw-blank.png',
iconSize: [32, 32], // size of the icon
iconAnchor: [16, 32], // point of the icon which will correspond to marker's location
popupAnchor: [0, -16] // point from which the popup should open relative to the iconAnchor
});

var [latitude, longitude] = latlong.split(',');
var marker = L.marker([latitude, longitude], {icon: blueMarkerSmall, zIndexOffset: 1000});
const [latitude, longitude] = latlong.split(',');

marker.addTo(_markerFeatureGroup)
.bindPopup(popupText);
const popupDiv = '<div class="qth">' +
'<h1>' + popupText + '</h1><hr/>' +
'</div>';

_markers.push(marker);
marker = createMarker(latitude, longitude, popupDiv, {zIndexOffset: 1000});
marker._icon.classList.add("qth-icon");
return marker;
}

/* addMarkerforQth - add a marker to the map for a given operating location */

/* TODO: Does not look like this function is used anywhere, remove in next revision
/* addMarkerforQth - add a marker to the map for a given operating location
*
* TODO: This function is for when we load QTH from ADIF File.
* It is not currently used.
*/
function addMarkerForQth(qth) {
var latlon = latLonForQso(qth);
if (latlon == null) {
return null;
}

var [latitude, longitude] = latlon;
var popupText = '<div class="qth">' +
'<h1>' + qth.call + '</h1><hr/>' +
'</div>';
marker = createMarker(latitude, longitude, popupText);
return marker;
const [latitude, longitude] = latlon;
const popupText = "Home QTH";
return createQTHMarker(`${latitude},${longitude}`, popupText);
}
*/

/* addMarkerForQso - add a marker to the map for a given QSO */
function addMarkerForQso(qso) {
Expand Down

0 comments on commit ba7e9cb

Please sign in to comment.