GithubHelp home page GithubHelp logo

MarkerOptions about android-maps-utils HOT 6 CLOSED

googlemaps avatar googlemaps commented on August 22, 2024
MarkerOptions

from android-maps-utils.

Comments (6)

ericpanorel avatar ericpanorel commented on August 22, 2024

Checkout the demo CustomMarkerClusteringDemoActivity
In there:
1.) A custom renderer is set

 mClusterManager.setRenderer(new PersonRenderer());

2.) And then, inside the renderer, the method "onBeforeClusterItemRendered" was implemented to tweak the icon.

from android-maps-utils.

ryust avatar ryust commented on August 22, 2024

I don't want to just tweet the icon... I keep track of maker data with the title and snippet attributes. Also, how do I define the anchor? Or a flat marker? There really should be a way to pass MarkerOptions to a ClusterItem instead so that markers can be created as before. This would allow developers to more easily integrate the clustering utils into existing apps.

from android-maps-utils.

ericpanorel avatar ericpanorel commented on August 22, 2024

To track any data associated with the marker, it is best to create a hashmap of marker ID vs. you data model, the best place to implement this is also in the renderer class by implementing the method:

@Override
protected void onClusterItemRendered(Person person, Marker marker) {
    super.onClusterItemRendered(person, marker);
    markerPersonMap.put(marker.getId(), person);
}

When implementing the method, onBeforeClusterItemRendered, you have MarkerOptions object passed in as the second parameter. You can then modify it from there.

markerOptions.title("Blah")
                      .snippet("some property from the first parameter object...")
                     .flat(true);

from android-maps-utils.

ryust avatar ryust commented on August 22, 2024

Gave it the college try, but got too cumbersome particularly if you want an option to turn off clustering. It would be soooooo much better if this was designed more simply and integrated into existing maps code so that you could do something like this (and ONLY this):

clusterManager.addMarker(markerOptions); // versus mapView.getMap().addMarker(markerOptions);
clusterManager.removeMarker(marker); // versus marker.remove();

This way clustering could very easily fit into existing implementations without tons of retooling.

from android-maps-utils.

broady avatar broady commented on August 22, 2024

You can still add a marker to the map directly.

map.addMarker(markerOptions)

Does that help?

from android-maps-utils.

cowboycoder avatar cowboycoder commented on August 22, 2024

While you could do this by implementing a CustomRenderer as ericpanorel noted above, I found it simpler to modify the utility library to allow the setting of MarkerOptions on a per item basis.

I added a new method on the ClusterItem interface, that supplies the MarkerOptions about to be applied

void applyMarkerOptions(MarkerOptions opts);

Then call this from the DefaultClusterRenderer, line 793, before the call to onBeforeClusterItemRendered()

++ item.applyMarkerOptions(markerOptions);
onBeforeClusterItemRendered(item, markerOptions);

Then your implementation of MyClusterItem can store the options you want applying, and apply them as needed.

from android-maps-utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.