getUrl method

String getUrl(
  1. TileCoordinates coords,
  2. int tileSize,
  3. bool retinaMode
)

Implementation

String getUrl(TileCoordinates coords, int tileSize, bool retinaMode) {
  final tileSizePoint = CustomPoint(tileSize, tileSize);
  final nwPoint = coords.scaleBy(tileSizePoint);
  final sePoint = nwPoint + tileSizePoint;
  final nwCoords = crs.pointToLatLng(nwPoint, coords.z.toDouble());
  final seCoords = crs.pointToLatLng(sePoint, coords.z.toDouble());
  final nw = crs.projection.project(nwCoords);
  final se = crs.projection.project(seCoords);
  final bounds = Bounds(nw, se);
  final bbox = (_versionNumber >= 1.3 && crs is Epsg4326)
      ? [bounds.min.y, bounds.min.x, bounds.max.y, bounds.max.x]
      : [bounds.min.x, bounds.min.y, bounds.max.x, bounds.max.y];

  final buffer = StringBuffer(_encodedBaseUrl);
  buffer.write('&width=${retinaMode ? tileSize * 2 : tileSize}');
  buffer.write('&height=${retinaMode ? tileSize * 2 : tileSize}');
  buffer.write('&bbox=${bbox.join(',')}');
  return buffer.toString();
}