New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a new menu item "Favorite Locations" in the navigation. #2552
base: develop
Are you sure you want to change the base?
Conversation
static/js/map.common.js
Outdated
}, | ||
'favoritesLocations': { | ||
default: [{ | ||
'Amsterdam': {lat: 52.3702157, lng: 4.895167899999933, zoom: 13, deletable: false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leave the default list blank.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no problem, but then we need a documentation :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - add an example to custom.js.example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done :)
static/js/map.js
Outdated
googleSearchBox.addListener('place_changed', function () { | ||
var place = googleSearchBox.getPlace() | ||
|
||
if (!place.geometry) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're not using semicolons, please use:
if (!place.geometry) {
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a code snippet from RM itself. But I can change that.
static/js/map.js
Outdated
* Favorit-location | ||
* first run load locations from settings / localStorage | ||
*/ | ||
function initFavoLocation() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initFavoLocation
-> initFavoriteLocations
static/js/map.common.js
Outdated
@@ -1065,6 +1065,15 @@ var StoreOptions = { | |||
'isSearchMarkerMovable': { | |||
default: false, | |||
type: StoreTypes.Boolean | |||
}, | |||
'favoritesLocations': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
favoritesLocations
-> favoriteLocations
templates/map.html
Outdated
@@ -427,6 +427,46 @@ <h3>Use Pokémon cries</h3> | |||
</div> | |||
</div> | |||
{% endif %} | |||
|
|||
<h3><i class="fa fa-binoculars fa-fw"></i>Favorites Locations</h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be under 'Location & Search Settings'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the overview I have separated it, but if it is desired I can do that. It would fit in there too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a seperate category alongside 'Marker Settings', 'Location & Search Settings' etc?
(If so then leave it for now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I would say
static/js/map.js
Outdated
|
||
var searchLocationInput = document.getElementById('search-favorit-location-input') | ||
if (searchLocationInput) { | ||
var googleSearchBox = new google.maps.places.Autocomplete(searchLocationInput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to specify a locality here, using the location specified in the config?
Setting the locality helps reduce errors caused by multiple places with the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this part is from RM and uses the google API. I do not know if you can do something like that. But basically this is a google search and the locality is displayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So from memory Google allows you to pick a location to find results near.
e.g. If you were in London, Ohio (in the US) setting the locality to 'United States' would give you the result that you were looking for: London, Ohio, US, rather than the more searched-for: London, UK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Leave this for now then.
You've misspelt 'favorite' throughout. Perhaps a language issue? |
Possible.. my native language is not english.. |
@pogo-excalibur |
I'd suggest changing the 'floppydisk' icon to a 'plus'-symbol. And maybe a few px's space between buttons/textfields? Just for the eye :p |
@darkelement1987 why not a floppydisk?
|
Great feature btw. Similar to something I've done with custom.js on my map, but better! 👍 |
static/js/custom.js.example
Outdated
@@ -11,6 +11,10 @@ $(function () { | |||
const upscalePokemon = false // Enable upscaling of certain Pokemon (upscaledPokemon and notify list). Default: false. | |||
const upscaledPokemon = [] // Add Pokémon IDs separated by commas (e.g. [1, 2, 3]) to upscale icons. Default: []. | |||
|
|||
// Add predefined buttons for favorit location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
favorit
-> favorite
And because this is an example file you don't need to use a comment to specify the format, you can just use code:
const favoriteLocations = [
{
lat: 40.7828647,
lng: -73.9653551,
zoom: 16,
deletable: false
}
]
static/js/custom.js.example
Outdated
@@ -83,6 +87,10 @@ $(function () { | |||
Store.set('showLocationMarker', showLocationMarker) | |||
Store.set('isLocationMarkerMovable', isLocationMarkerMovable) | |||
|
|||
if (Store.get('favoriteLocations')[0] === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intention here to check if there are any favoriteLocations set?
If so use if (Store.get('favoriteLocations').length === 0) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is also a possibility – done
static/js/map.js
Outdated
@@ -509,6 +509,134 @@ function initSidebar() { | |||
} | |||
|
|||
$('#pokemon-icon-size').val(Store.get('iconSizeModifier')) | |||
|
|||
$('#add-favorit-location-button').on('click', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
favorit
-> favorite
(This needs changing throughout)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you still found something.. shame on me :-/
Description
This will insert a new menu item "Favorite Locations" in the navigation with three functions:
with the first function, users can search for places like neighborhoods, streets, etc. (This code was already in RM. I only changed it a bit.)
the second function allows the user to save the current view as "quick button". Each view can be assigned an own name. This buttons can be deleted again at any time by the user.
and the third feature allows the site admins to leave predefined locations as "quick button". These can be stored as deletable or non-deletable buttons. The predefined gps coordinates are stored in the custom.js
A few examples:
(result see Screenshots)
Motivation and Context
These functions are very helpful to save hotspots like nests, or if the site admin scans only some places (or a large area), he can deposit these places as a "quick button". The places created by the user are stored in the localstorage and will not be publicly available. Therefore, my other PR (#2545) is very useful to restore the settings in case of loss.
How Has This Been Tested?
I use it on my map. I just changed it a bit for publishing and to make it more user-friendly.
Screenshots (if appropriate):
Types of changes
Checklist: