Dynamic markers update

5 views
Skip to first unread message

Johan Euphrosine

unread,
Dec 1, 2010, 12:24:53 PM12/1/10
to Tile5, development team
Hi,

In order to redraw T5.ImageAnnotation in a T5.MarkerLayer after having
updated their position. we needed to expose private markerUpdate
function like this:

diff --git a/dist/tile5.js b/dist/tile5.js
index e124999..546b9bd 100644
--- a/dist/tile5.js
+++ b/dist/tile5.js
@@ -5947,6 +5947,10 @@ T5.MarkerLayer = function(params) {

return animating ? 1 : 0;
},
+
+ update: function() {
+ markerUpdate();
+ },

add: add,
clear: clear,

And then call:
annotation.xy = new (T5.Geo.GeoVector)(new (T5.Geo.Position)(p.x, p.y));
map.markers.update();

We were wondering if there is a better way to do it ?

Johan Euphrosine

unread,
Dec 1, 2010, 12:31:47 PM12/1/10
to Tile5, development team
On Wed, Dec 1, 2010 at 6:24 PM, Johan Euphrosine <pro...@aminche.com> wrote:
> Hi,
>
> In order to redraw T5.ImageAnnotation in a T5.MarkerLayer after having
> updated their position. we needed to expose private markerUpdate
> function like this:

Here is a small demo to illustrate our point:
http://playground.mekensleep.com/~proppy/more-tile5hacking/

Jeremy Arnold

unread,
Dec 1, 2010, 3:13:24 PM12/1/10
to ti...@googlegroups.com
This was something I came across too... would be keen to be able to
animate markers as well.
I think I ended up using map.markers.add(false) to trigger an update
of the marker layer as I was pressed for time.

Jeremy

Damon Oehlman

unread,
Dec 1, 2010, 6:04:39 PM12/1/10
to ti...@googlegroups.com
Hey Guys,

I'm having a look at this now, and rather than expose the markerUpdate function, I'm thinking that I would be better to provide a move method on the T5.Annotation that allows you to update the xy position of a marker and have everything updated correctly without having to do anything tricky.

Essentially, I'm going to create a new T5.Marker class (which is wrapped by T5.Annotation for backwards compatibility).  One of the things I did wrong was to expose the annotation.xy and have it feel like it was an updatable property.  While it can be changed, you guys have already found out that it really doesn't just update as it should.  As such, I would propose that a marker now gets a "move" method that you can pass a T5.Vector (or T5.Geo.GeoVector) to tell the marker it needs to change position.  The method would be more efficient than a full markerUpdate as only the modified marker would have screen coordinates recalculated, etc (in the case of a GeoVector anyway).

I'll try and push something to the sandbox today to demonstrate - I think you will be pleased with the change.

Cheers,
Damon.
--
Damon Oehlman
http://distractable.net/

Damon Oehlman

unread,
Dec 2, 2010, 12:39:00 AM12/2/10
to ti...@googlegroups.com
Hey Guys,

Well, I've added something and it's more inline with the original request than what I thought I was going to do.  This is primarily because I was anticipating the next thing that might have been asked for is being able to rotate an image.

Check out this sandbox demo and let me know if you think this will work for what you are trying to do:


Cheers,
Damon.
Reply all
Reply to author
Forward
0 new messages