amMap support forum

You are not logged in.

Announcement

FORUM CLOSED! This forum is closed. We moved to a new place at Zendesk. Update your bookmarks.

amMap for Flex: Help on amMap for Flex


#1 2011-01-06 00:21:56

chokobu22
New member

calling a Flex function while click on node

Hi Sir/Madam,

Is is possible to call a Flex function while clicking on a pin on a map? Currently the pin is added in AS3 as a MapMovie.

If I wish to store some value on the pin (MapMovie), how can I store it and retrieve it?

Offline

 

#2 2011-01-06 03:17:06

marcelionis
Administrator

Re: calling a Flex function while click on node

Map objects have value property, also customData property which can accept any object.

There is clickMapObject event to amMap:

clickMapObject="{handleClick(event)}"

then you'll be able to find which object was clicked and retrieve value/customData:

            private function handleClick(event:MapObjectEvent):void{
                trace(event.mapObject.value);
                trace(event.mapObject.customData);
            }

Offline

 

#3 2011-01-06 04:29:04

chokobu22
New member

Re: calling a Flex function while click on node

Can I add click even to the MapMovie class? This is how I do it currently:

Code:

                var dataSet:DataSet = new DataSet();
                dataSet.mapClass=_world;
                dataSet.leftLongitude=-168.49;
                dataSet.topLatitude=83.63;
                dataSet.rightLongitude=190.3;
                dataSet.bottomLatitude=-55.58;

                var tst:MapMovie = new MapMovie;
                tst.lat =60;
                tst.long=-0.1275;
                tst.movieClass = _test
                tst.balloonText = "bollon";
                tst.customData = "this is custom data"


                myBalloon = new AmBalloon;
                myBalloon.setStyle("fillColor","#FFFF00");

                dataSet.movies.push(tst);

                myMap.dataSets = [dataSet];
                myMap.balloon = myBalloon

If use MapObject, I am unsure how to add MapObject to the Map using AS3 code.

Thanks!

Steven

Offline

 

#4 2011-01-07 02:09:02

marcelionis
Administrator

Re: calling a Flex function while click on node

MapMovie is not a visual element, so it can't have a click event. You could add click event on displayObject of the MapMovie, but I wouldn't recommend it. The method described above will work much better.

You should use dataSet.addObject(mapmovie) method to add movies dynamically.

Offline

 

#5 2011-01-07 04:04:42

chokobu22
New member

Re: calling a Flex function while click on node

Thanks for the advise.

With mapobject, I found no long or lat method for it.  If I want to bind an image to a class, and display it by added it to mapobject/mapmovie on the map with click function binded and able to retrieve custom data, how should I approach this?

Last edited by chokobu22 (2011-01-07 04:20:29)

Offline

 

#6 2011-01-07 05:43:57

marcelionis
Administrator

Re: calling a Flex function while click on node

MapMovie has long/lat properties. MapObject is a base class for MapMovie, MapArea and MapLine and can't be used directly. You should use MapMovie to display images. You can path to your image using movieURL property or embed image and set it using movieClass property.
MapObject has a property customData, use it to store your custom data and then you can register clicks and retrieve custom data using method which I described in my first reply to this post.

Offline

 

#7 2011-01-07 09:33:06

chokobu22
New member

Re: calling a Flex function while click on node

By using the code below, I am still unable to get customdata from tst when I click on the icon image(MapMovie) on the map. Please help, thanks!!

Code:

 private function init():void{
                var dataSet:DataSet = new DataSet();
                dataSet.mapClass=_world;
                dataSet.leftLongitude=-168.49;
                dataSet.topLatitude=83.63;
                dataSet.rightLongitude=190.3;
                dataSet.bottomLatitude=-55.58;

                var tst:MapMovie = new MapMovie;
                tst.lat =60;
                tst.long=-0.1275;
                tst.movieURL="assets/images/icon.png"
                tst.balloonText = "bollon";
                tst.customData = "this is custom data"

                dataSet.addObject(tst)

                myMap.dataSets = [dataSet];
            }

    private function handleClick(event:MapObjectEvent):void{
                trace(event.mapObject.value);
                trace(event.mapObject.customData);

            }

  <ammap:AmMap id="myMap" width="600" height="400" visible="true" clickMapObject="{handleClick(event)}"  >

        </ammap:AmMap>

Offline

 

#8 2011-01-08 04:20:42

marcelionis
Administrator

Re: calling a Flex function while click on node

My mistake, you should add
tst.url="";

line (or set zoomLevel/description for the movie). If non of the mentioned is set, the clicking on the movie is disabled.

Offline

 

© amMap & amCharts | Forum engine: PunBB