transformations on custom markers

83 views
Skip to first unread message

HungDo

unread,
Jun 21, 2011, 10:53:01 AM6/21/11
to openscales-dev
Hi I am relatively new to openscales, been learning and working on it
for about 3 weeks now.

I have run across an issue that I hope someone here can assist me
with.

The issue is creating a Custom Marker such as a arrow icon that would
rotate to point in the direction of your heading IN a map.

I have tried using the rotateZ to accomplish this but it seems the
origin is not the center of the icon;
the icon does however rotates to the correct direction but the
position of the icon is well off from the original position.

I looked into it a bit but all I found out was that there was some
relation to some parent class.

I figure the best option would be to do a transformation after the
rotation but that does seem to work.

Can anyone here shed some more light as to how the rotate functions
work?



HungDo

unread,
Jun 22, 2011, 12:29:09 PM6/22/11
to openscales-dev
*correction second to last sentence* I figure the best option would be
to do a transformation after the rotation but that DOESN'T seem to
work.

Romaric Pascal

unread,
Jun 22, 2011, 5:58:16 PM6/22/11
to opensca...@googlegroups.com
Hi !

Your issue reminds me a lot of this one : http://groups.google.com/group/openscales-dev/browse_thread/thread/644b62595a6036d3/bc36a69e953a21ce. Have you tried the code provided by the original poster ?

Regards,
Rhum



2011/6/22 HungDo <Hun...@lmnsolutions.com>
*correction second to last sentence* I figure the best option would be
to do a transformation after the rotation but that DOESN'T seem to
work.

--
You received this message because you are subscribed to the Google Groups "openscales-dev" group.
To post to this group, send email to opensca...@googlegroups.com.
To unsubscribe from this group, send email to openscales-de...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openscales-dev?hl=en.


HungDo

unread,
Jun 23, 2011, 1:40:45 PM6/23/11
to openscales-dev
Yea I have tried it already with a line. What I am doing is rotating
an icon around a fixed point, the center of the image. I've been
looking into AffineTransforms to solve this but the problem is
"projecting" the rotation transformations on to the map.

Hung

geogeek11

unread,
May 7, 2012, 12:36:53 PM5/7/12
to opensca...@googlegroups.com
hello,
have you found a solution for your problem , because i have the same issue :( , if yes would you share the solution :)

geogeek11

unread,
May 7, 2012, 1:03:28 PM5/7/12
to opensca...@googlegroups.com
thanks :) , i have found the solution :)



var bm:Bitmap=new iconFlag3();
bm.rotation=Number(direction-180) ;
var marker:CustomMarker = CustomMarker.createDisplayObjectMarker(bm, new Location(Number(Loc[1]),Number(Loc[0])));


elsewhere in the file  =>
[Bindable]
[Embed("images/flags/iconFlag3.png")]
public var iconFlag3:Class;

i hope it could help someone

geogeek11

unread,
May 8, 2012, 7:09:19 PM5/8/12
to opensca...@googlegroups.com
that's was not really the solution because i have encountered another problem of displacements while zooming in or out, so the best method should be  custommarker.rotation = angle

but it doesn't work for me, when i set an angle different from 0 the marker disappear from the map ,  any help will be very helpful.

thanks in advance

WillPetty

unread,
May 9, 2012, 10:15:39 AM5/9/12
to opensca...@googlegroups.com
one thing you need to be careful of when rotating a custom marker image is making sure the image content is the the middle of the image.
if for example the image is a 50x50 bitmap and you have a arrow image in that really only takes up the top left 5x10 pixels, then when you rotate the image its going to be displaced.

I'm not sure if this is the displacement issue you are having, but just thought it might be something you haven't thought about.
what I have usually done in this sort of case is create a Sprite with a bitmap in it, then rotate the sprite with something like sprite.rotation = 90;
and then if its not a image that has the content directly in the middle of a square, then i offset the image based on how much it was rotated and the size of the image. and i just add that offset in the  CustomMarker.createDisplayObjectMarker() function.

Hope that helps.

-Will
Reply all
Reply to author
Forward
0 new messages