moagrius / MapViewDemo

7 stars 4 forks source link

Adding grouping to the marker items #1

Open klattimer opened 11 years ago

klattimer commented 11 years ago

I'm trying to adapt this code to group markers (and ungroup them) actively as the view zooms, I'm having difficulty understanding how your markers code works. In the iOS implementation of our map code I created a pair of classes one is a "location" the other is a "marker", marker deals with displaying the markers and location deals with the locations which the markers represent, when the markers are close together they will join into a single marker.

Could you either give me some pointers on how to add this functionality or contact me directly and we can work out this functionality together.

moagrius commented 11 years ago

There are built-in methods for showing markers at only particular zoom levels: addMarkerAtZoom

If that doesn't satisfy your needs, you'll need to manage them directly. Implement a MapEventListener and show/hide markers based on whatever conditions you require, testing on whatever events seem appropriate to you (most likely onZoomChanged (more efficient) or onScaleChanged (more frequent)).

HTH

klattimer commented 11 years ago

On 19 Jun 2013, at 18:42, moagrius notifications@github.com wrote:

There are built-in methods for showing markers at only particular zoom levels: addMarkerAtZoom

If that doesn't satisfy your needs, you'll need to manage them directly. Implement a MapEventListener and show/hide markers based on whatever conditions you require, testing on whatever events seem appropriate to you (most likely onZoomChanged (more efficient) or onScaleChanged (more frequent)).

HTH

Thanks that's great, I actually found more or less that this was the way forward for this, I'm pretty new at android but an old hat at iOS - I'm finding the difference to be like comparing a jet powered car to a push bike :/

One thing that worries me significantly is whether or not the widget is snappy enough for doing the realtime updates of the markers. In iOS I just threw a bunch of fade in/out's of views in UIView animations targeting android 4+ with this. Not sure how I'm going to replicate the animations if at all but we'll see :)

Do you want me to send you a pull request with what I implement?

moagrius commented 11 years ago

Thanks that's great, I actually found more or less that this was the way forward for this, I'm pretty new at android but an old hat at iOS - I'm finding the difference to be like comparing a jet powered car to a push bike

I do both (iOS and Android), and while I agree that Cocoa is much easier and iOS generally is more predictable and powerful, I don't know that I'd call Andorid a "push bike" :) It takes a while to get used to how things are done, and the documentation (official and community based) isn't as mature as iOS's, but once you get past the hump things start come together.

One thing that worries me significantly is whether or not the widget is snappy enough for doing the realtime updates of the markers. In iOS I just threw a bunch of fade in/out's of views in UIView animations targeting android 4+ with this. Not sure how I'm going to replicate the animations if at all but we'll see :)

Depends on how you're showing them - if you're displaying based on scale (which updates frequently), you might not want to - if you're displaying based on something else (taps, or zoom level changes), you're probably fine. In the sample app I use animation to display callouts without any hiccups. That said, I know CATiledLayed fades in tile changes - I had this in originally but under stress (pinching between levels), on older devices, this was leading to out-of-memory errors. I'm sure it could be done, and I might take a stab at it in TileView (see below), but for this iteration definitely do not try to animate tiles.

Do you want me to send you a pull request with what I implement?

Actually this version is about to be superceded, so no. However, I'd be very interested to see the final implementation "in the wild". Anyway, I have one commit locally I haven't pushed yet (which I should do this week), but that's likely to be the last one for this repo (by me, anyways). There are some API-breaking changes I want to implement, and we've decided to rename the project (there's already an Android MapView widget, and the component here gets used for a lot more than maps, so it's going to become "TileView"). The core functionality will be the same, but I'm going to normalize some things, improve others, and add some more: https://github.com/moagrius/MapView/issues/57