Skip to content

[Feature request]: I'm trying to add a custom maker on target location , but I didnot find any such option in package. #428

@umairAbbasi7

Description

@umairAbbasi7

Is there an existing issue for this?

  • I have searched the existing issues

Use case

Marker( markerId: 'custom_marker', options: navigation.MarkerOptions( icon: customDescriptor, infoWindow: navigation.InfoWindow(title: "Custom Marker"), ), ); have this option but im unable to show on map please helppp

Proposal

Future _startCurrentNavigation(context) async {
if (currentWaypointIndex >= waypointsQueue.length) {
log("All waypoints navigated.");
return;
}
var provider = Provider.of(context, listen: false);

if (provider.rideRequest?.rideStatus == "started") {
  monitorCurrentWaypointDistance(context, provider.rideRequest!);
}
log("finally starting navigation");
final waypoint = waypointsQueue[currentWaypointIndex];
final destinations = navigation.Destinations(
  waypoints: [waypoint],

  displayOptions: navigation.NavigationDisplayOptions(
    showDestinationMarkers: true,
    showStopSigns: true,
    showTrafficLights: true,
  ),
  routingOptions: navigation.RoutingOptions(
    travelMode: navigation.NavigationTravelMode.driving,

    alternateRoutesStrategy:
        navigation.NavigationAlternateRoutesStrategy.all,
    routingStrategy: navigation.NavigationRoutingStrategy.defaultBest,
  ),
);
// 👉 Create + set marker before setting destinations
final customDescriptor = await createCustomMarkerDescriptor();
final customMarker = navigation.Marker(
  markerId: 'custom_marker',
  options: navigation.MarkerOptions(
    icon: customDescriptor,
    infoWindow: navigation.InfoWindow(title: "Custom Marker"),
  ),
);

final status = await navigation.GoogleMapsNavigator.setDestinations(
  destinations,
);

if (status == navigation.NavigationRouteStatus.statusOk) {
  navController?.followMyLocation(navigation.CameraPerspective.tilted);
} else {
  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      content: Text('Failed to start navigation: $status ${status.name}, '),
    ),
  );
}

}

Future<navigation.ImageDescriptor> createCustomMarkerDescriptor() async {
final ByteData byteData = await loadMarkerImage(
'assets/markers/carIcon.png',
);

final descriptor = await navigation.registerBitmapImage(
  bitmap: byteData,
  imagePixelRatio: 2.0, // adjust if needed
  width: 40, // logical pixels
  height: 40,
);

return descriptor;

}

// This will load your PNG from assets
Future loadMarkerImage(String assetPath) async {
return await rootBundle.load(assetPath);
}

Metadata

Metadata

Assignees

Labels

triage meI really want to be triaged.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions