Skip to content

Commit

Permalink
Place find me results on the sketch layer
Browse files Browse the repository at this point in the history
This makes it easier to reference, remove, edit, change the results of
the find me service.
  • Loading branch information
theduckylittle committed Nov 8, 2024
1 parent ec90cbe commit df4cce3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/services/findme.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2017 Dan "Ducky" Little
* Copyright (c) 2016-2024 Dan "Ducky" Little
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -31,7 +31,7 @@
function FindMeAction(Application, options) {

// allow the targetting of a layer, but default to the highlight layer
this.targetLayer = options.targetLayer ? options.targetLayer : 'results/results';
this.targetLayer = options.targetLayer ? options.targetLayer : 'sketch/default';

// default the map projection to web-mercator
this.mapProjection = options.mapProjection ? options.mapProjection : 'EPSG:3857';
Expand All @@ -50,7 +50,11 @@ function FindMeAction(Application, options) {
*/
this.run = function(selection, fields) {
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(this.gotoPosition.bind(this), (e) => { console.error(e); alert("Find Me: " + e.message); }, { enableHighAccuracy: true });
navigator.geolocation.getCurrentPosition(
this.gotoPosition.bind(this),
(e) => { console.error(e); alert("Find Me: " + e.message); },
{ enableHighAccuracy: true }
);
} else {
alert('Geolocation is not supported.');
}
Expand All @@ -76,8 +80,6 @@ function FindMeAction(Application, options) {
// put the feature in map projection.
var map_feature = gm3.util.projectFeatures([fake_feature], 'EPSG:4326', this.mapProjection)[0];

Application.clearFeatures(this.targetLayer);

// mark the location in the highlight layer
Application.addFeatures(this.targetLayer, map_feature);

Expand Down

0 comments on commit df4cce3

Please sign in to comment.