Skip to content

Commit

Permalink
Fix icons not working on web
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwillian0 committed May 29, 2023
1 parent 9d23c6a commit fe33aec
Show file tree
Hide file tree
Showing 17 changed files with 5 additions and 2 deletions.
Binary file modified assets/accessory_icons/bug_report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/business_center.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/credit_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/directions_car.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/directions_walk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/favorite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/language.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/pedal_bike.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/pets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/place.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/push_pin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/redeem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/school.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/visibility.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/vpn_key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/accessory_icons/work.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions lib/map/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class _AccessoryMapState extends State<AccessoryMap> {
void Function()? cancelLocationUpdates;
void Function()? cancelAccessoryUpdates;
bool accessoryInitialized = false;
bool mapStyleLoaded = false;

@override
void initState() {
Expand Down Expand Up @@ -85,11 +86,13 @@ class _AccessoryMapState extends State<AccessoryMap> {
}

updateMarkers(MapboxMapController controller, UnmodifiableListView<Accessory> accessories) async {
mapStyleLoaded = true;
controller.removeCircles(controller.circles);
controller.removeSymbols(controller.symbols);

Set<String> iconStrings = accessories.map((accessory) => accessory.iconString).toSet();
for (String iconString in iconStrings) {
// to convert from svg to RGBA png use `convert -background "rgba(0,0,0,0)" $f png32:${f%.*}.png`
await addImageFromAsset(controller, iconString, "assets/accessory_icons/$iconString.png");
}

Expand All @@ -111,7 +114,7 @@ class _AccessoryMapState extends State<AccessoryMap> {
.map((accessory) => SymbolOptions(
geometry: accessory.lastLocation!,
iconImage: accessory.iconString,
iconSize: 1.0,
iconSize: 0.425 * MediaQuery.of(context).devicePixelRatio,
textField: accessory.name,
textColor: "#000000",
textOffset: const Offset(0, 1.5),
Expand All @@ -132,7 +135,7 @@ class _AccessoryMapState extends State<AccessoryMap> {
accessoryInitialized = true;
}

if (_mapController != null) {
if (mapStyleLoaded) {
updateMarkers(_mapController!, accessories);
}

Expand Down

0 comments on commit fe33aec

Please sign in to comment.