MarkerOptions.fromJson constructor

MarkerOptions.fromJson(
  1. Map<String, dynamic> json
)

Create object from the given JSON object.

Implementation

MarkerOptions.fromJson(Map<String, dynamic> json) {
  bool isPropertySet = false;
  if (json['anchorPoint'] != null) {
    if (json['anchorPoint'] is Map<String, dynamic>) {
      anchorPoint = WoosPoint.fromJson(json['anchorPoint']);
      isPropertySet = true;
    } else {
      Util.showWarning(
          "`anchorPoint` should be an object of Map<String, dynamic>");
    }
  }

  if (json['clickable'] != null) {
    clickable = json['clickable'] as bool;
    isPropertySet = true;
  }

  if (json['draggable'] != null) {
    draggable = json['draggable'] as bool;
    isPropertySet = true;
  }

  if (json['icon'] != null) {
    if (json['icon'] is String) {
      _icon = json['icon'].toString();
      isPropertySet = true;
    } else if (json['icon'] is Map<String, dynamic>) {
      _icon = WoosIcon.fromJson(json['icon']);
      isPropertySet = true;
    } else {
      Util.showWarning(
          'icon should either be a string or json representation of WoosIcon object.');
    }
  }

  if (json['label'] != null) {
    if (json['label'] is String) {
      _label = json['label'].toString();
      isPropertySet = true;
    } else if (json['label'] is Map<String, dynamic>) {
      _label = MarkerLabelOptions.fromJson(json['label']);
      isPropertySet = true;
    } else {
      Util.showWarning(
          'label should either be a string or json representation of WoosmMarkerLabelOptions object.');
    }
  }

  if (json['opacity'] != null) {
    opacity = json['opacity'].toDouble();
    isPropertySet = true;
  }

  if (json['position'] != null) {
    if (json['position'] is Map<String, dynamic>) {
      position = LatLng.fromJson(json['position']);
      isPropertySet = true;
    } else {
      Util.showWarning(
          "`position` should be an object of Map<String, dynamic>");
    }
  }

  if (json['title'] != null) {
    title = json['title'].toString();
    isPropertySet = true;
  }

  if (json['visible'] != null) {
    visible = json['visible'] as bool;
    isPropertySet = true;
  }

  if (!isPropertySet) {
    Util.showWarning(
        "No valid properties found in given map for MarkerOptions.");
  }
}