You are not logged in.
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
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
Can I add click even to the MapMovie class? This is how I do it currently:
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 = myBalloonIf use MapObject, I am unsure how to add MapObject to the Map using AS3 code.
Thanks!
Steven
Offline
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
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
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
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!!
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
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