MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
image_source.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mbgl/style/source.hpp>
4 #include <mbgl/util/image.hpp>
5 
6 #include <optional>
7 
8 namespace mbgl {
9 class LatLng;
10 class AsyncRequest;
11 
12 namespace style {
13 
14 class ImageSource final : public Source {
15 public:
16  ImageSource(std::string id, std::array<LatLng, 4>);
17  ~ImageSource() override;
18 
19  std::optional<std::string> getURL() const;
20  void setURL(const std::string& url);
21 
23 
24  void setCoordinates(const std::array<LatLng, 4>&);
25  std::array<LatLng, 4> getCoordinates() const;
26 
27  class Impl;
28  const Impl& impl() const;
29 
31 
32  bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
33 
34  mapbox::base::WeakPtr<Source> makeWeakPtr() override {
35  return weakFactory.makeWeakPtr();
36  }
37 
38 protected:
39  Mutable<Source::Impl> createMutable() const noexcept final;
40 
41 private:
42  std::optional<std::string> url;
43  std::unique_ptr<AsyncRequest> req;
44  mapbox::base::WeakPtrFactory<Source> weakFactory {this};
45 };
46 
47 template <>
48 inline bool Source::is<ImageSource>() const {
49  return getType() == SourceType::Image;
50 }
51 
52 } // namespace style
53 } // namespace mbgl
const Impl & impl() const
bool supportsLayerType(const mbgl::style::LayerTypeInfo *) const override
std::optional< std::string > getURL() const
void setCoordinates(const std::array< LatLng, 4 > &)
std::array< LatLng, 4 > getCoordinates() const
Mutable< Source::Impl > createMutable() const noexcept final
void setImage(PremultipliedImage &&)
void setURL(const std::string &url)
ImageSource(std::string id, std::array< LatLng, 4 >)
void loadDescription(FileSource &) final
mapbox::base::WeakPtr< Source > makeWeakPtr() override
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
Definition: actor.hpp:15
Definition: tile_id.hpp:256