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

Improve or customize InfoWindow #3085

Closed
cuong-td opened this issue Nov 20, 2015 · 15 comments
Closed

Improve or customize InfoWindow #3085

cuong-td opened this issue Nov 20, 2015 · 15 comments
Labels
Android Mapbox Maps SDK for Android iOS Mapbox Maps SDK for iOS

Comments

@cuong-td
Copy link

Please tell me if we can display an info window like this in Android with Mapbox.
unsupportedmapbox2
https://drive.google.com/file/d/0B4_M3f30IWv0Zm5NYm9ON05yTnM/view?usp=sharing

Thanks in advance.

@friedbunny friedbunny added the Android Mapbox Maps SDK for Android label Nov 20, 2015
@tobrun
Copy link
Member

tobrun commented Nov 20, 2015

@vns-cuong

InfoWindowAdapter

You can use the InfoWindowAdapter to achieve this effect. This interface will be called when you click on a Marker and allows you to adapt the contents to a View instead of the default InfoWindow.

Example

An example of this can be found here.

@tobrun tobrun closed this as completed Nov 20, 2015
@cuong-td
Copy link
Author

@tobrun Great! Thanks so much 👍

@cuong-td
Copy link
Author

@tobrun Please help me again!
Does iOs support it as well? Please give me some trace for it.

Thank you in advance.

@tobrun
Copy link
Member

tobrun commented Nov 20, 2015

@friedbunny
How can you achieve this on iOS?

@tobrun tobrun reopened this Nov 20, 2015
@friedbunny
Copy link
Contributor

iOS doesn't support this level of callout customization yet, though #3013 might add it.

For now on iOS, it's only possible to customize the title/subtitle, and the left/right accessory views. See:

@friedbunny friedbunny added the iOS Mapbox Maps SDK for iOS label Nov 20, 2015
@fffaria
Copy link

fffaria commented Sep 6, 2016

I don't get it. What is the name of the library that we need to use to create the custom marker window for android ? (InfoWindowAdapter). I can't import the correct library in order to use the function "getInfoWindow", for instance. It seems like the dependency I imported in does not have classes that can handle the custom marker window. (I am using the 4.2.0 Beta.2 SDK) It can't resolve the method at "setInfoWindowAdapter".

I have searched all over the internet for custom marker library, I have found out that I had to use Google maps's own InfoWindowAdapter, I do not wish to open another issue for that kind of thing. Can you guys help me out? Thanks! @vns-cuong @tobrun @friedbunny

@tobrun
Copy link
Member

tobrun commented Sep 6, 2016

@leminur you don't need another library for this. It's included in the SDK itself as an inner class within MapboxMap:

 /**
     * Interface definition for a callback to be invoked when an info window will be shown.
     *
     * @see MapboxMap#setInfoWindowAdapter(InfoWindowAdapter)
     */
    public interface InfoWindowAdapter {
        /**
         * Called when an info window will be shown as a result of a marker click.
         *
         * @param marker The marker the user clicked on.
         * @return View to be shown as a info window. If null is returned the default
         * info window will be shown.
         */
        @Nullable
        View getInfoWindow(@NonNull Marker marker);
    }

@ppanero
Copy link

ppanero commented Oct 4, 2016

@vns-cuong @tobrun @friedbunny Hey there! I am in a similar problem. I cannot resolve the "setInfoWindowAdapter" is it true as @leminur stated that Google Map's class has to be imported? In the doc it appears to be on MapView class but is not resolving.

Just in case Im using v4.1.1 for android

Thanks for the help in advance.

@tobrun
Copy link
Member

tobrun commented Oct 5, 2016

You should be able to resolve it against mapboxmap, not mapview. Will need to double check the documentation.

@ppanero
Copy link

ppanero commented Oct 5, 2016

@tobrun Thank you very much :D

@ghost
Copy link

ghost commented Nov 22, 2016

Is it possible to control the positioning of the info window returned by getInfoWindow() in an implementation of InfoWindowAdapter? I tried to call offsetTopAndBottom() on it before returning it, and the info window is positioned at the specified offset relative to the marker when it first appears. But when I start dragging the map, the info window is moved to the default position relative to the marker.

@nielsfalk
Copy link

@tobrun Is it possible to get something like an info-window for the SymbolLayer?

@tobrun
Copy link
Member

tobrun commented Dec 18, 2017

@nielsfalk yes, that is possible, I would suggest adding a second symbolLayer. An example of such an integration is found in this example. More concretely the InfoWindow code (aka callout) is found in this method. LMK if you need more information, we are currently working on a blogpost highlighting these features.

@nielsfalk
Copy link

thx @tobrun
it took me a wile to find out that the trick is to inflate the a BubbleLayout into a bitmap.
hidden in line (635)

@moorthysubu
Copy link

How to implement multiple clicks widgets in the info window view as this example showing up bitmap as the info window basically

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

No branches or pull requests

7 participants