Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Change icon of a Marker when zoomlevel changes #5451

Closed
guruduttstay opened this issue Jun 23, 2016 · 10 comments
Closed

Change icon of a Marker when zoomlevel changes #5451

guruduttstay opened this issue Jun 23, 2016 · 10 comments
Labels
Android Mapbox Maps SDK for Android annotations Annotations on iOS and macOS or markers on Android

Comments

@guruduttstay
Copy link

Platform: Android
Mapbox SDK version:4.1.0-beta

Steps to trigger behavior

  1. Allow setting/adding multiple Icons to Marker and allow setting to display it at certain zoom level.
  2. For e.g. if added two Icons iconA, iconB then Display iconA from zoom level 1 to 9 and display iconB from Zoom level 9 to 21
  3. Best would be allow adding different layers to map, all markers added to those layers and it should be possible to control those layers dynamically (e.g. show, hide layers based on Zoom level and other callbacks )

Expected behavior

Actual behavior

I found clustering but that's not what we want :(

Let me know if this is already possible. ... I didn't found it in code or doc yet

@tobrun tobrun added Android Mapbox Maps SDK for Android annotations Annotations on iOS and macOS or markers on Android labels Jun 23, 2016
@tobrun
Copy link
Member

tobrun commented Jun 23, 2016

@guruduttstay thank you for reaching out, what you are requesting is indeed support for z-layers. We are tracking this feature in #5238. With the 4.1.0-beta we are exposing some support for z-ordering but not in a way that would solve your request in this issue. Closing as a duplicate with #5238.

@1ec5
Copy link
Contributor

1ec5 commented Jun 23, 2016

This request is about varying a marker icon based on the zoom level, not about arranging multiple markers in z-space.

Once #837 is fully implemented in the SDK, it’ll be possible to do this with GeoJSON point features and potentially GL-rendered markers, but those changes alone won’t make it possible with marker views.

@1ec5 1ec5 reopened this Jun 23, 2016
@tobrun
Copy link
Member

tobrun commented Jun 24, 2016

@1ec5 thank you for the info on #837. I initially thought this part of the feature request was not something that the SDK would expose and that end developers would implement theirselves using OnCameraChangeListener. I'm going to change the title to make the request itself a bit more clear.

@tobrun tobrun changed the title Multiple icon for same Marker Change icon of a Marker when zoomlevel changes Jun 24, 2016
@tobrun
Copy link
Member

tobrun commented Jun 24, 2016

@guruduttstay if urgent, you could try using the OnCameraChangeListener to determine changes in zoom level and update your markers accordingly. We currently don't expose an API to do this on large scale (using the concept of a layer) but the feature itself should be possible.

@guruduttstay
Copy link
Author

guruduttstay commented Jun 24, 2016

@1ec5 thank you for reopening issue :)
@tobrun it is kind of urgent ... this is one of the strongest feature in our App we want to implement with MapBox :(

I will try OnCameraChangeListener and get back here if that solves our issue, I am concern about performance :)

@1ec5
Copy link
Contributor

1ec5 commented Jun 24, 2016

Can you give us more details about the effect you're trying to achieve with zoom-dependent icons in marker views? For example, are you trying to have the icon's size vary? That information could help us decide on a better API, if any.

@guruduttstay
Copy link
Author

Hi @1ec5

Just recorded screen for current implementation :)
http://bit.ly/28XZPyi

For more info may be you can try Stay.com App from playstore or app store :)

@SylvainHocq
Copy link
Contributor

I'm also interested by this feature.

@1ec5
Copy link
Contributor

1ec5 commented Aug 17, 2016

Android SDK v4.2.0-beta.1 and iOS SDK v3.2.0-alpha.1 both have support for runtime styling. As long as the icons in question are baked into the style at design time (for example in Mapbox Studio), you can have symbol features transition between the icons based on zoom levels using a zoom function on the iconImage property.

Note that the runtime styling API only supports symbol features, not marker views (Android) or annotation views (iOS). At runtime, you can put point data inside a GeoJSON source and style it using a symbol layer. If you need this functionality for marker views or annotation views, please try the approach described in #5451 (comment).

@cammace
Copy link
Contributor

cammace commented Nov 9, 2016

@guruduttstay and @SylvainHocq, like @1ec5 mentioned, runtime styling has been implemented in the Android SDK now which supports symbol layers. You might find this example particularly useful, along with the other many examples you can find here. Feel free to reach out through our contact page if you guys have any additional questions on how to achieve this. Happy to help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android annotations Annotations on iOS and macOS or markers on Android
Projects
None yet
Development

No branches or pull requests

5 participants