How can I use full API if I create a map with flex.Maps MXML component?
With Flex Builder 2 and the as3 library, I can successfully build a basic map by editing your SampleFlexClient.mxml. I'd like to add markers to the map, but the flex.Maps component does not yet support the full API. As a workaround, within a Script block I attempt to get an instance of the map (using the getter function) and then add markers. But, the markers won't appear. I'm new to Flex and ActionScript, so I'm sure that I'm doing something wrong. Can you please help? My code is included below (working off revision 318 of the subversion repository) :
<mx:application>
<modest:map>
<mx:script>
<![CDATA[
import com.modestmaps.Map;
import com.modestmaps.events.*;
import com.modestmaps.geo.Location;
public var map:com.modestmaps.Map;
public function more():void {
map = mainMap.map;
map.addEventListener(MarkerEvent.ENTER, onMarkerEnters);
map.addEventListener(MarkerEvent.LEAVE, onMarkerLeaves);
map.putMarker('Rochdale', new Location(37.865571, -122.259679));
}
private function onMarkerEnters(event:MarkerEvent):void {
trace('+ '+event.marker+' =)');
}
private function onMarkerLeaves(event:MarkerEvent):void {
trace('- '+event.marker+' =(');
}
]>
</mx:script>
</modest:map></mx:application>
<mx:application>
<modest:map>
<mx:script>
<![CDATA[
import com.modestmaps.Map;
import com.modestmaps.events.*;
import com.modestmaps.geo.Location;
public var map:com.modestmaps.Map;
public function more():void {
map = mainMap.map;
map.addEventListener(MarkerEvent.ENTER, onMarkerEnters);
map.addEventListener(MarkerEvent.LEAVE, onMarkerLeaves);
map.putMarker('Rochdale', new Location(37.865571, -122.259679));
}
private function onMarkerEnters(event:MarkerEvent):void {
trace('+ '+event.marker+' =)');
}
private function onMarkerLeaves(event:MarkerEvent):void {
trace('- '+event.marker+' =(');
}
]>
</mx:script>
</modest:map></mx:application>
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?For some reason "Satisfaction" altered my post and removed the content from the root mx:Application node and the modest:Map node. They are as follows:
mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:modest="com.modestmaps.flex.*"
modest:Map id="mainMap" top="0" left="0" bottom="0" right="0"
provider="BLUE_MARBLE" zoom="4" center="37, -100" draggable="true"
creationComplete="more()" -
Inappropriate?Sorry, we haven't yet implemented the full marker API in the AS3 port yet, let alone the Flex component. The AS3 port doesn't create visible markers like the AS2 one does currently, but it should keep track of the marker objects and dispatch MarkerEvents when they enter and leave the map. If not, then that's a bug, and it's something we'll have to fix when we get in there to get the AS3 port up to speed.
2 people say
this answers the question
-
Inappropriate?Thanks for the reply. Any estimates on when the AS3 port will be complete? Just wondering if its better to start my project in AS2.
Also, when you say that it should keep track of marker objects and trigger MarkerEvents, does that mean it provides information about where the marker should be in the current stage/frame (x, y, coordinates)? Hence, could I draw my own markers independent of the modestmaps API? Thanks again. -
Inappropriate?I just added the question about AS3 port as its own topic:
http://getsatisfaction.com/modestmaps...
I’m happy
-
Inappropriate?It appears that I can add a marker to the grid's MarkerSet using putMarker() in Maps.as, but the marker is not being tracked. Running in debug-mode, onMarkerEnters() and onMarkersLeaves() in Map.as are never called by updateMarkers() in TileGrid.as. Hence, the MarkerEvents don't get dispatched. Any ideas? Again, it could be my fault, here's my new AS3 block:
<mx:script>
<![CDATA[
import com.modestmaps.Map;
import com.modestmaps.events.*;
import com.modestmaps.geo.Location;
public var map:com.modestmaps.Map;
public function more():void {
map = mainMap.map;
map.addEventListener(MarkerEvent.ENTER, markerEntersHandler);
map.addEventListener(MarkerEvent.LEAVE, markerLeavesHandler);
map.putMarker('Rochdale', new Location(37.865571, -122.259679));
}
public function markerEntersHandler(event:MarkerEvent):void {
trace('+ '+event.marker+' =)');}
public function markerLeavesHandler(event:MarkerEvent):void {
trace('- '+event.marker+' =(');}
]>
</mx:script>
Loading Profile...



