Skip to content

Commit

Permalink
added showing marker on locations
Browse files Browse the repository at this point in the history
  • Loading branch information
Chamidilshan committed Aug 21, 2023
1 parent 247f56a commit b522b1e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Binary file added assets/dest_marker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 19 additions & 1 deletion lib/views/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:flutter/services.dart' show rootBundle;
import 'package:google_places_flutter/google_places_flutter.dart';
import 'package:jeitak_app/views/my_profile_screen.dart';
import 'package:geocoding/geocoding.dart' as geoCoding;
import 'dart:ui' as ui;

class HomeScreen extends StatefulWidget {
HomeScreen({Key? key}) : super(key: key);
Expand Down Expand Up @@ -51,6 +52,7 @@ class _HomeScreenState extends State<HomeScreen> {
rootBundle.loadString('assets/map_styles.txt').then((string) {
_mapStyle = string;
});
loadCustomMarker();
}

void signOutUser(){
Expand Down Expand Up @@ -235,7 +237,7 @@ class _HomeScreenState extends State<HomeScreen> {
title: 'Destination: $controller.text',
),
position: destination,
//icon: BitmapDescriptor.fromBytes(markIcons),
icon: BitmapDescriptor.fromBytes(markIcons),
));

myMapController!.animateCamera(CameraUpdate.newCameraPosition(
Expand Down Expand Up @@ -820,6 +822,22 @@ class _HomeScreenState extends State<HomeScreen> {
);
}

late Uint8List markIcons;

loadCustomMarker() async {
markIcons = await loadAsset('assets/dest_marker.png', 100);
}

Future<Uint8List> loadAsset(String path, int width) async {
ByteData data = await rootBundle.load(path);
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(),
targetHeight: width);
ui.FrameInfo fi = await codec.getNextFrame();
return (await fi.image.toByteData(format: ui.ImageByteFormat.png))!
.buffer
.asUint8List();
}

buildDrawerItem(
{required String title,
required Function onPressed,
Expand Down

0 comments on commit b522b1e

Please sign in to comment.