mapbox-plugins-android icon indicating copy to clipboard operation
mapbox-plugins-android copied to clipboard

InfoWindow support / selected states

Open tobrun opened this issue 6 years ago • 22 comments

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.

tobrun avatar Sep 05 '18 13:09 tobrun

@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.

jeffypooo avatar Feb 04 '19 01:02 jeffypooo

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?

constantinevassil avatar Feb 11 '19 18:02 constantinevassil

@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.

tobrun avatar Feb 11 '19 19:02 tobrun

@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?

constantinevassil avatar Feb 11 '19 21:02 constantinevassil

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

Sent with GitHawk

jeffypooo avatar Feb 12 '19 17:02 jeffypooo

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=)

klblk avatar Mar 27 '19 07:03 klblk

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?

mortezahosseinee avatar May 07 '19 08:05 mortezahosseinee

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

LukasPaczos avatar May 07 '19 09:05 LukasPaczos

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

langsmith avatar May 07 '19 15:05 langsmith

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.

mortezahosseinee avatar May 08 '19 05:05 mortezahosseinee

@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.

LukasPaczos avatar May 08 '19 09:05 LukasPaczos

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

langsmith avatar May 14 '19 15:05 langsmith

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
  • [x] support title/message API
  • [ ] support View based API
  • [ ] support fills and lines -> requires additional turf ports

tobrun avatar Jun 28 '19 14:06 tobrun

@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?

mrfaa avatar Nov 12 '19 16:11 mrfaa

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.

brandikun avatar Dec 23 '19 22:12 brandikun

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

OsamaMuhammad avatar May 13 '20 12:05 OsamaMuhammad

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)

TarasOsiris avatar May 27 '20 16:05 TarasOsiris

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

wshihdehx avatar Jun 06 '20 21:06 wshihdehx

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
  • [x] put code into a plugin

  • [x] support style reloading

  • [x] 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 avatar Jun 06 '20 21:06 wshihdehx

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 avatar Jun 06 '20 21:06 wshihdehx

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

wshihdehx avatar Jun 07 '20 02:06 wshihdehx

@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:

  • https://github.com/tobrun
  • https://github.com/LukasPaczos
  • https://github.com/langsmith

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.

tir38 avatar Jul 22 '20 01:07 tir38