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

InfoWindow support / selected states #649

Open
tobrun opened this issue Sep 5, 2018 · 22 comments
Open

InfoWindow support / selected states #649

tobrun opened this issue Sep 5, 2018 · 22 comments

Comments

@tobrun
Copy link
Member

tobrun commented Sep 5, 2018

With #647 we are adding the abillity to react on symbol click events. An extended use-case of this is to introduce selected states and showing an InfoWindow as result of it.

@jeffypooo
Copy link

@tobrun any idea when this will get released? We briefly experimented with replacing our current marker/info window functionality with this plugin (and the marker view plugin), but could not figure out a clean way to do callouts. This is/was pretty easy to do with MapboxMap.setInfoWindowAdapter.

If this is low on the priority list we can try and implement and send a PR.

@constantinevassil
Copy link

Callout is essential basic functionality.

What I need is the following:

  1. the user taps on the map.
  2. the App gets lat/lng
  3. lat/lng is searched in map features
  4. from the feature the App gets several fields like Title, Description.

Looking at the code:
https://github.com/mapbox/mapbox-android-demo/blob/master/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/dds/InfoWindowSymbolLayerActivity.java

I can load "us_west_coast.geojson" to get the initial structure and dynamically update the location and Title, Description, etc.

It seems if I call refreshSource and have featureCollection already populated with lat/lng, Title, Description, etc. I can do that.

private void refreshSource() {
if (source != null && featureCollection != null) {
source.setGeoJson(featureCollection);
}
}

Now the question is how to create new featureCollection dynamically?

@tobrun
Copy link
Member Author

tobrun commented Feb 11, 2019

@masterjefferson I'm aware that this is highly requested feature and I would love to prioritize this but with other pieces moving, I can't say I will be able to pick this is up the near future. The idea is that a InfoWindow would be a SymbolLayer on it's own which contents are static and we would probably need to opt to create a SymbolLayer per InfoWindow.

@topinvestor the idea behind geojson is that the should be perceived as immutable. So you can create new FeatureCollection instances with the multiple static creator methods as FeatureCollection.fromFeatures.

@constantinevassil
Copy link

constantinevassil commented Feb 11, 2019

@tobrun "the idea behind geojson is that the should be perceived as immutable. So you can create new FeatureCollection instances with the multiple static creator methods as FeatureCollection.fromFeatures"

I think this is what we need - could you please point me to example or just copy paste the relevant code how to populate FeatureCollection for this purpose. If I know how to do that I can do it that way.

What was able to do is:

...
private FeatureCollection featureCollection;
private GeoJsonSource source;

...
private void refreshSource(LatLng position) {

If I have just one feature I can get it as follows:
//
PROPERTY_NAME = "name";
name = featureList.get(0).getStringProperty(PROPERTY_NAME);
//
//
PROPERTY_NAME = "description";
description = featureList.get(0).getStringProperty(PROPERTY_NAME);
//

   featureList.get(0) is as follows:

Feature{type=Feature, bbox=null, id=null,
geometry=Point{type=Point, bbox=null,
coordinates=[-117.5952959, 33.6388097]},
properties={"marker-color":"#7e7e7e","marker-size":"medium","marker-symbol":"",
"name":"California",
"description":"Modern counter-service spot serving locally sourced, organic soups, sandwiches, bowls & baked goods.",
}}

If call refreshSource and initialize
source.setGeoJson
with these fields: ** name**, ** description** and ** coordinates** (with position.getLongitude() and position.getLongitude()), this is all what is needed to do it dynamically.

It is like this:
Feature feature = Feature.fromGeometry(Point.fromLngLat(position.getLongitude(), position.getLatitude())
);

The new info:
feature.addStringProperty(PROPERTY_NAME, name);

The new info:
feature.addStringProperty(PROPERTY_NAME, capital);

At the end:

new GenerateViewIconTask(MainActivity.this).execute(featureCollection);

Would update the pin and the callout info to new information

So basically I regenerate the bitmap with the new info and can see it on the map.

Would there be any side effects with new GenerateViewIconTask like memory leak, etc?

@jeffypooo
Copy link

@tobrun understood, we'll look into a symbol layer implementation. We may send over a
PR for this 🤓

Sent with GitHawk

@klblk
Copy link

klblk commented Mar 27, 2019

Is this supposed to be part of annotation-plugin?
I am not interested in using plugin (does not solve my problems), but I use custom SymbolLayers and I need to show InfoWindow when clicking.
Maybe my tasks are too specific and I have to suffer=)

@LukasPaczos LukasPaczos removed this from the annotation-0.6.0 milestone Apr 5, 2019
@mortezahosseinee
Copy link

mortezahosseinee commented May 7, 2019

Hi everybody. i have a situation, need help. i add a marker to map and onMapClick get first feature from getProjection and show an info window with custom layout, i used
map.setInfoWindowAdapter(marker -> { ... })
everythings is ok. now i upgrade mapbox version from 6.0.2 to 7.3.2. so i add symbol layer and i have same task. //show info window on click of symbol layer points that info window has custom layout. i can't proceed, so go to add marker approach and using setInfoWindowAdapter but i faced this: setInfoWindowAdapter is Depricated... and i searched it and get this :
depricated com.mapbox.mapboxsdk.maps.MapboxMap.setInfoWindowAdapter(MapboxMap.InfoWindowAdapter)
As of 7.0.0, use Mapbox Annotation Plugin instead:
https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation
i can't get my goal with this link, anybody can help me?

@LukasPaczos
Copy link
Member

@mortezahosseinee check out the already linked in this topic SymbolLayer example of how to implement an info window.

@langsmith
Copy link
Contributor

@mortezahosseinee , https://docs.mapbox.com/android/maps/examples/symbol-layer-info-window/ is what the example that @LukasPaczos linked to above, looks like.

@mortezahosseinee
Copy link

mortezahosseinee commented May 8, 2019

Thank you for your attention. But I need show info window with custom layout, i saw these links ago. if you don't understand my point, tell me explain more.

@LukasPaczos
Copy link
Member

@mortezahosseinee in this case, https://docs.mapbox.com/android/maps/examples/symbollayer-mapillary/ might be helpful - it shows how to convert a custom layout into a bitmap, supply it to the map and make it interactive.

@langsmith
Copy link
Contributor

it shows how to convert a custom layout into a bitmap, supply it to the map and make it interactive.

https://docs.mapbox.com/android/maps/examples/symbol-layer-info-window/ also converts a custom layout to a bitmap

@tobrun
Copy link
Member Author

tobrun commented Jun 28, 2019

Sorry for the delay on this feature. I have a small POC working:

ezgif com-video-to-gif (80)

To make this a supported SymbolManager feature we still need:

  • correct anchor placement of the callout that takes in account:
    • iconAnchor
    • iconSize
    • iconDimension
  • put code into a plugin
  • support style reloading
  • support title/message API
  • support View based API
  • support fills and lines -> requires additional turf ports

@mrfaa
Copy link

mrfaa commented Nov 12, 2019

@tobrun Any update on this feature request?

I also need a supported SymbolManager Feature to display an InfoWindow above an Marker after clicking this marker.

Do you have the code from your POC?

@brandikun
Copy link

I would also really appreciate an update on this. I am working on a GIS-lite project on Android and I am starting to realize that most libraries including mapbox are just not meant for GIS functionality. If anyone sees this and has any other suggestions, please let me know.

@OsamaMuhammad
Copy link

OsamaMuhammad commented May 13, 2020

@tobrun Any update on this feature request? I need to display a custom info window on symbol click.

@TarasOsiris
Copy link

TarasOsiris commented May 27, 2020

Hello, it would be really great to have this functionality as a part of the plugin since the iOS annotations plugin supports this out of the box. (basically having title and subtitle in SymbolOptions)

@wshihdehx
Copy link

wshihdehx commented Jun 6, 2020

@tobrun Is there a reason why this feature hasn't been implemented since it was requested in 2018?

@wshihdehx
Copy link

wshihdehx commented Jun 6, 2020

Sorry for the delay on this feature. I have a small POC working:

ezgif com-video-to-gif (80)

To make this a supported SymbolManager feature we still need:

  • correct anchor placement of the callout that takes in account:

    • iconAnchor
    • iconSize
    • iconDimension
  • put code into a plugin

  • support style reloading

  • support title/message API

  • support View based API

  • support fills and lines -> requires additional turf ports

Hey @tobrun do you know when will this go live?

@wshihdehx
Copy link

I looked into using the symbol layer example here but it's too messy, MapBox should be making things easy, why do we have to write so much boilerplate code for a simple info window?

@tobrun

https://github.com/mapbox/mapbox-android-demo/blob/master/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/dds/InfoWindowSymbolLayerActivity.java

@wshihdehx
Copy link

Hello, it would be really great to have this functionality as a part of the plugin since the iOS annotations plugin supports this out of the box. (basically having title and subtitle in SymbolOptions)

I know man, it's been 3 years already, talk about slow, these are very basic features, I love MapBox but seriously they need to get these things added in Google Maps API it's so easy to do these simple things without having to write too much boiler plate code

@tir38
Copy link

tir38 commented Jul 22, 2020

@wshihdehx plz don't spam this repo with requests. Plz don't open other issues that do nothing but point back to this issue.

I know it looks like sometimes things move slowly, but take the time to see what has been worked on that was higher priority in the last three years. You can start by reviewing all commits in this repo:

https://github.com/mapbox/mapbox-plugins-android/commits/master

You should also look at contribution graphs of the main devs who do work on this project to see what else they spend their time on:

Lastly, this is an OS project so if you really want this feature, you can try to build it yourself. Read the contribution page for more info.

If you just want to show your interest in getting this built a simple 👍 on the OP would probably be worth more than your four comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests