Get your own customer support community
 

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>
Inappropriate?
1 person has this question

User_default_medium