Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OSM attribution in the examples that use OSM tiles #128

Open
Maximkaaa opened this issue Feb 2, 2025 · 5 comments · May be fixed by #155
Open

Add OSM attribution in the examples that use OSM tiles #128

Maximkaaa opened this issue Feb 2, 2025 · 5 comments · May be fixed by #155
Labels
good first issue Good for newcomers T-enhancement Improve an existing feature
Milestone

Comments

@Maximkaaa
Copy link
Owner

As per OSM Tile Usage Policy we must include attribution on the map.

The best way to do it would be to add a method to the Layer trait that would return the attribution string, and then make EguiMap collect such attributions and display them in the right place over the map.

@Maximkaaa Maximkaaa added good first issue Good for newcomers T-enhancement Improve an existing feature labels Feb 2, 2025
@Maximkaaa Maximkaaa added this to the 0.2 milestone Feb 2, 2025
@siddheshzz
Copy link

Hi I am new to rust can i give it a try

@Maximkaaa
Copy link
Owner Author

Maximkaaa commented Feb 6, 2025 via email

@Maximkaaa
Copy link
Owner Author

Here are some details for the implementation:

  1. Since OSM requires the attribution to contain a link to their site, it would be a good idea to make the new method return a struct, that will contain attribution text and an optional url to link to.
  2. The correct attribution for OSM should be added to the RasterTileLayer::with_osm() method and to the examples in docs that use OSM url. Some of those example can be replaced with the with_osm() method (they were written before this method existed).
  3. It would be great to check MapTiler term and conditions and if they require attribution (I am almost sure they do), add it to the vector tile examples.

Don't hesitate to ask if you have any questions.

@siddheshzz
Copy link

siddheshzz commented Feb 17, 2025

Thanks for the suggestions. Please bare with me.
We can have a attribution() method in Layers which we can use for Vector, raster and features.
I tried to understand the code starting from raster_tile.rs example ( went back to all function calls and definitions of what is happening)

I am not getting how can we render/ show this on map.

  1. Tried adding attribution on RasterTileLayer like:
pub fn new(
        tile_schema: TileSchema,
        tile_provider: impl RasterTileProvider + 'static,
        messenger: Option<Arc<dyn Messenger>>,
    ) -> Self {
           
          Self {
            tile_provider: Arc::new(tile_provider),
            tile_schema,
            prev_drawn_tiles: Mutex::new(vec![]),
            fade_in_duration: Duration::from_millis(300),
            tiles: Arc::new(Cache::new(5000)),
            messenger,
            attribution: Self::with_osm(),
        }
    }

fn with_osm()-> Attribution {
        Attribution {
            text: "© OpenStreetMap contributors",
            url: "https://www.openstreetmap.org/copyright",
        }
    }


impl Layers for RasterTileLayer{
.
.

fn attribution(&self) -> Attribution {
        self.attribution.clone()
        
    }
}
  1. MapTiler does require the attribution once i get this one right i will do that as well

Could you please point me to right direction I think i am missing a lot here

@Maximkaaa
Copy link
Owner Author

Displaying attribution on the map is not the work of the Map per se, but of the UI environment that draws the map. In case of our examples, we use integration with egui by the EguiMap in the galileo-egui crate. To add the attribution text, add a new ui.label() at the end of .render method. You can see some examples of how to use egui in the egui-app example, or go to their demo.

siddheshzz added a commit to siddheshzz/galileo that referenced this issue Feb 21, 2025
@siddheshzz siddheshzz linked a pull request Feb 21, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers T-enhancement Improve an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants