Skip to content

Better profile icons#379

Merged
karussell merged 19 commits intographhopper:masterfrom
SachsenspieltCoding:better-profile-icons
May 6, 2024
Merged

Better profile icons#379
karussell merged 19 commits intographhopper:masterfrom
SachsenspieltCoding:better-profile-icons

Conversation

@SachsenspieltCoding
Copy link
Contributor

fixes #376

Better profile icons

This PR changes the behaviour of the profile icons, which is an addition to #368.

Icons can be added simpler

// ALL AVAILABLE ICONS
// every svg gets mapped to a key, so icons can be easily added
export const icons = {
    car: CarIcon,
    small_truck: SmallTruckIcon,
    truck: TruckIcon,
    scooter: ScooterIcon,
    foot: FootIcon,
    hike: HikeIcon,
    bike: BicycleIcon,
    mtb: MtbBicycleIcon, // Mountainbike
    racingbike: RacingbikeIcon,
    motorcycle: MotorcycleIcon,
    wheelchair: WheelchairIcon,
    question_mark: QuestionMarkIcon,
}

From now on, the icons are defined with a map inside the profileIcons.ts. Every available SVG get's mapped to a specific key, so it will automatically be used, without any further code changes.

Replaced question marks with numbers

image

When there is no icon available for that profile, an incremental number will be displayed.

Icons based on prefix

Icons now get their icons, based on their prefix. While standard profiles like car or foot still get their default icon, every profile with one of those as a prefix also gets the same base icon, but with a small number in the top right corner. Therefore, icons for custom profiles are now supported in a way.

Example
image

... car_delivery, car_avoid_ferry, car_avoid_motorway, car_avoid_toll, small_truck_delivery, ...

@karussell
Copy link
Member

Nice! This looks much better and works already great.

One question I have this config:

 profiles: {
       car_delivery: {},
       car: {},
       car_avoid_some: {},
       small_truck_1: {},
       something: {},
}

And somehow it starts counting at 0 for car and small_truck:

image

And should we include "car" in the list of "car* prefixes"? I.e. in the case above it would then result in a list "car 1","car 2","car 3"?

@SachsenspieltCoding
Copy link
Contributor Author

Oh, that is a bug, right.
This could easily be fixed if, as you said, we did not include car itself in the list of profiles with car as a prefix, as it is ignored anyway, so is obsolete.

@SachsenspieltCoding
Copy link
Contributor Author

@karussell Should be fixed now

@SachsenspieltCoding
Copy link
Contributor Author

grafik

@karussell karussell merged commit 65a7497 into graphhopper:master May 6, 2024
ZeroGxMax pushed a commit to minhhpkp/graphhopper-maps that referenced this pull request Nov 12, 2024
* added translations

* added german translation for towerslope

* update german translations

* replaced questions marks with numbers and added custom icon option

* reformat code

* added batch numbers to prevent duplicate icons

* removed icon option in config; improved visabillity of batchNumbers

* moved icons to seperate files; optimization

* bug fix

* separate empty key from default profile name

* a little less code

* improved key selection while creating customProfiles Record

* separate empty key from default profile name (#1)

* separate empty key from default profile name

* a little less code

---------

Co-authored-by: Peter <graphhopper@gmx.de>
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.

Change icon for unknown profiles?

2 participants