Skip to Content
SAP Flash Island and Google Maps… – it’s so obvious – and therefore I had to try to build an example of how this could be done – just as an inspiration.  If you are familar with Google Maps – you might be thinking: JavaScript… ! and how could this be integrated with Flex… well.. Google has made it a little bit easier for Flex developers with the Google Maps API for Flash . All you need to do is to register in order to get an API Key and then download the SWC file: map_flex_1_6.swc and include it in the library path of your project. With the SWC file you will get access to the Google Maps interface library.


And why could it be helpfull to integrate Google Maps with SAP using Flash Islands? Well… it’s just one of those examples which illustrate some of the basic ideas of SAP Flash Island – you embed a powerfull UI with SAP which isn’t available in SAP Netweaver. And with this feature it’s suddenly easy to show e.g.:

    • where your customers are located
    • which installations needs a visit from a service technician
    • where is the nearest truck
    • and more…

You just need to pass either the GPS coordinate or the address of the location(s) to your Flash Island – and the Flash Island will handle the rest. The gecoding feature in Google will help you with the address conversions to GPS coordinates.

 

 

Remember to include the SAP Flash Island swc’s into your library path as well – see example here


Example source code below – replace the API key and the initial address in the example below.


if you want to try it without the SAP Flash lib – just remove:
           

public var inputAddress:String;

private var gMap:Map;

private var MyCurrentLocation:String;

private function init():void

{
FlashIsland.register(this);

gMap = new Map();

gMap.key = "enter your api key here - enter your api key here";

gMap.width = 600;

gMap.height = 400;

gMap.addEventListener(MapEvent.MAP_READY, mapReadyHandler);

mapContainer.addChild(gMap);

if ( inputAddress == null )

{

inputAddress = "your initial location"

addr1.text = inputAddress;

}

}

private function mapReadyHandler(e:MapEvent):void

{

gMap.setCenter(new LatLng(55.999121,9.540081), 4 ,
MapType.NORMAL_MAP_TYPE);

gMap.setSize(new Point(mapContainer.width, mapContainer.height));

gMap.addControl(new PositionControl());

gMap.addControl(new ZoomControl());

gMap.addControl(new MapTypeControl());

FindMyLocation();

}

public function FindMyLocation():void

{

doGeocode();

}

private function doGeocode():void

{

var geocoder:ClientGeocoder = new ClientGeocoder("AU");

geocoder.addEventListener(GeocodingEvent.GEOCODING_SUCCESS,
function(event:GeocodingEvent):void

{

var placemarks:Array = event.response.placemarks;

if (placemarks.length > 0)

{

gMap.setCenter(placemarks[0].point);

var marker:Marker = new Marker(placemarks[0].point);

marker.addEventListener(MapMouseEvent.CLICK,
function (event:MapMouseEvent):void

{

marker.openInfoWindow(new InfoWindowOptions(
{content: placemarks[0].address}));

});


                           marker.setOptions(new MarkerOptions(), fillStyle:
                           new FillStyle(), radius: 12,

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply