toJson method
Implementation
Map<String, dynamic> toJson() {
final Map<String, dynamic> json = <String, dynamic>{};
void addIfPresent(String fieldName, dynamic value) {
if (value != null) {
json[fieldName] = value;
}
}
addIfPresent('width', Platform.isAndroid ? width.toInt() : width);
addIfPresent('height', Platform.isAndroid ? height.toInt() : height);
if (bounds != null) {
if (_platformWrapper.isAndroid) {
final featureCollection = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
bounds!.northeast.longitude,
bounds!.northeast.latitude
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
bounds!.southwest.longitude,
bounds!.southwest.latitude
]
}
}
]
};
addIfPresent("bounds", featureCollection.toString());
} else {
final list = [
[
bounds!.southwest.latitude,
bounds!.southwest.longitude,
],
[
bounds!.northeast.latitude,
bounds!.northeast.longitude,
]
];
addIfPresent("bounds", list);
}
}
if (centerCoordinate != null && zoomLevel != null) {
if (_platformWrapper.isAndroid) {
final feature = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
centerCoordinate!.longitude,
centerCoordinate!.latitude
]
}
};
addIfPresent('centerCoordinate', feature.toString());
} else {
final list = [
centerCoordinate!.latitude,
centerCoordinate!.longitude,
];
addIfPresent('centerCoordinate', list);
}
addIfPresent('zoomLevel', zoomLevel);
}
addIfPresent('pitch', pitch);
addIfPresent('heading', heading);
addIfPresent('styleUri', styleUri);
addIfPresent('styleJson', styleJson);
addIfPresent('withLogo', withLogo);
addIfPresent('writeToDisk', writeToDisk);
return json;
}