Skip to content
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

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

Ditto-IV100
Copy link

@Ditto-IV100 Ditto-IV100 commented Mar 26, 2018

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)

const 'favoriteLocations' = [{
        'Amsterdam': {lat: 52.3702157, lng: 4.8951678, zoom: 13, deletable: false},
        'Central Park (NY)': {lat: 40.7828647, lng: -73.9653551, zoom: 16, deletable: false},
        'London': {lat: 51.5073509, lng: -0.1277582, zoom: 14, deletable: true},
        'Berlin': {lat: 52.5200065, lng: 13.4049539, zoom: 14}
    }]

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):

favorites-locations

favorites-locations

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

},
'favoritesLocations': {
default: [{
'Amsterdam': {lat: 52.3702157, lng: 4.895167899999933, zoom: 13, deletable: false},
Copy link
Contributor

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.

Copy link
Author

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 :)

Copy link
Contributor

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

Copy link
Author

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
Copy link
Contributor

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
}

Copy link
Author

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initFavoLocation -> initFavoriteLocations

@@ -1065,6 +1065,15 @@ var StoreOptions = {
'isSearchMarkerMovable': {
default: false,
type: StoreTypes.Boolean
},
'favoritesLocations': {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

favoritesLocations -> favoriteLocations

@@ -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>
Copy link
Contributor

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'.

Copy link
Author

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

Copy link
Contributor

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)

Copy link
Author

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)
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it would look like this.
favorites-locations-ssearch

It's like "Change search location" which already exists in RM.

I do not know how I have to change that in the google-maps-api so it is focused on the location from the settings. But I do not think that this option is really necessary.

Copy link
Contributor

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.

@pogo-excalibur
Copy link
Contributor

You've misspelt 'favorite' throughout. Perhaps a language issue?

@Ditto-IV100
Copy link
Author

Possible.. my native language is not english..

@darkelement1987
Copy link
Contributor

Also 'Favorite Locations' can be 'Favorite locations' and 'Search location' here (lowercase)

image

@Ditto-IV100 Ditto-IV100 changed the title Adds a new menu item "Favorites Locations" in the navigation. Adds a new menu item "Favorite Locations" in the navigation. Mar 27, 2018
@Ditto-IV100
Copy link
Author

@pogo-excalibur
Apply changes

@darkelement1987
Copy link
Contributor

darkelement1987 commented Mar 27, 2018

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

@Ditto-IV100
Copy link
Author

Ditto-IV100 commented Mar 27, 2018

@darkelement1987 why not a floppydisk?

I found a bug, if no location is is preset. I will fix it. - done

@captbunzo
Copy link

Great feature btw. Similar to something I've done with custom.js on my map, but better! 👍

@@ -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
Copy link
Contributor

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
    }
]

@@ -83,6 +87,10 @@ $(function () {
Store.set('showLocationMarker', showLocationMarker)
Store.set('isLocationMarkerMovable', isLocationMarkerMovable)

if (Store.get('favoriteLocations')[0] === undefined) {
Copy link
Contributor

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) {

Copy link
Author

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 () {
Copy link
Contributor

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)

Copy link
Author

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 :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants