Development Trends

Archive for the ‘Maps’ Category

Google Analytics in SAP WebDynpro using SAP Flash Islands

with one comment

If you are doing Web development using SAP WebDynpro in Netweaver – you might find the fact that you cannot use Javascript in the UI a little bit annoying… so what do you do if you would like to use e.g. Google Analytics to monitor the usage of your WebDynpro application…? in order to do this you need to add a small Javascripts snippet to your webpages, and this is not possible in WebDynpro… or…. (btw: the same Javascript idea applies to other kinds of third party app’s.. not only Google apps)

Well.. I ran into a couple of links – and it gave me a good idea, that might help you embed Google Analytics.

  1. First of all your development platform need to support SAP Flash Islands (min. SAP NetWeaver 7.0 EhP1)
  2. Then you need to goto Google Analytics Tracking for Adobe Flash – in order to get the analytics.swc file
  3. Create a Google Analytics account in order to get an account-id for tracking
  4. Create a new SAP Flash Island application (click here to see an SAP Flash Island template)- and add the analytics.swc to the Flex build path/Library path – the Island should not display much… maybe just a company logo etc.
  5. The new SAP Flash Island application should take an url as an input parameter and pass this url to Google Analytics using the Google Analytics Tracking tool for Flash/Flex (see example) using the command: ”
    tracker.trackPageview( the input url parameter );"
  6. Place the new SAP Flash Island application on each of the WebDynpro pages you want to track (the visual size of the Island could but small or covered by a company log – you just need it somewhere on the page) – and pass the actual url of the WebDynpro Application parameter to the Island. You actually just use SAP Flash Island to call Google Analytics, so from a display point of view the output of the Island is not that interesting in this example
  7. And you will be able to start collecting the WebDynpro Usage in Google Analytics
  8. Remember to check the terms of service

Happy programming…

Written by MKE

May 4th, 2009 at 10:28 pm

SAP Flash Island and Google Maps

with 3 comments

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.  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 (marked with blue) – replace the parts marked with red.

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

  • import sap.FlashIsland:
  • FlashIsland.register(this)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    width="100%"
    height="100%"
    initialize="init()">
    <mx:Script >
        <![CDATA[
            import sap.FlashIsland;
            import mx.controls.Alert;
            import com.google.maps.controls.MapTypeControl;
            import com.google.maps.controls.ZoomControl;
            import com.google.maps.controls.PositionControlOptions;
            import com.google.maps.Map;
            import com.google.maps.MapEvent;
            import com.google.maps.MapType;
            import com.google.maps.LatLng;
            import com.google.maps.controls.PositionControl;
            import com.google.maps.overlays.Marker;
            import com.google.maps.overlays.MarkerOptions;
            import com.google.maps.styles.FillStyle;
            import com.google.maps.styles.StrokeStyle;
            import com.google.maps.InfoWindowOptions;
            import com.google.maps.MapMouseEvent;
            import com.google.maps.services.ClientGeocoder;
            import com.google.maps.services.GeocodingEvent;
            [Bindable]
            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({ strokeStyle:
                           new StrokeStyle({color: 0x987654}), fillStyle:
                           new FillStyle({color: 0x223344, alpha: 0.8}), radius: 12,
                           hasShadow: true }));
                        gMap.addOverlay(marker);
                      }
                });
                geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE,
                function(event:GeocodingEvent):void
                {
                    Alert.show("Location not found");
                    trace(event);
                    trace(event.status);
                  });
                gMap.clearOverlays();
                geocoder.geocode(addr1.text);
              }
        ]]>
    </mx:Script>
    <mx:Label id="lab1" text="Find Functional Location.." />
    <mx:TextInput id="addr1" />
    <mx:Button id="geocoding" label="Search" click="FindMyLocation()" />
    <mx:UIComponent id="mapContainer" width="100%" height="90%"/>
</mx:Application>

Written by MKE

February 5th, 2009 at 12:07 am

SAP ABAP developers: How to get started with Adobe FLEX – part II

with 2 comments

In my previous blog I described how you could find descriptions and inspirations on how to get started with Adobe FLEX development.

In this blog, I will focus a little bit more at some Adobe FLEX examples. But before we go into details, you need to get Adobe FLEX installed. There are two possibilities, you can either download the free Flex 3 SDK – with this download you will get the Flex Framework and the Flex compiler, which will enable you to develop and deploy Flex applications. But you will miss an IDE which is not part of the package. If you want to go for the full package you will have to download the Flex Builder 3 – Adobe has a trial download available. My ‘How-to-get-started’ examples will be based on Flex Builder 3.

After you have installed Flex Builder 3, you are ready to get started with the traditional ‘Hello world’ application:

  • Start Flex Builder 3
  • Choose ‘File -> New -> Flex Project’
  • Enter a project name ‘SAPSDNdemo1′
  • Application Type ‘Web Application (runs in Flash Player)

The Application type will determine whether the Flex application will run in a browser as a web application or as a desktop Adobe AIR application.

  • Copy/paste the sourcecode below (marked with blue) into the ‘Source’ tab:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        <![CDATA[
        import mx.controls.Alert;
        public function Button1Clicked():void
        {
            Alert.show('This is demo1', 'How to get started', mx.controls.Alert.OK);
        }
        ]]>
    </mx:Script>
    <mx:Label text="Hello - SAP Community Network"/>
    <mx:Button id="button1" label="Press me" click="Button1Clicked()" />
</mx:Application>
  • ‘Save’ the project
  • Choose ‘Run’

The ‘Hello world’ project will start in your browser (see/try the example below)

The sourcecode contains two types of elements:

  • MXML: Multimedia eXtensible Markup Language (mx: tag’s)
  • ActionScript

MXML is a markup language and is used to define the layout of the FLEX application and the binding between UI components. A large number of Flex UI components are available in Flex Builder.

ActionScript is used for the implementation of the application logic. ActionScript could be quite complex and built using OO.

In the example above, I have used mx-tag’s to define:

  • The general attributes of the application with mx:application
  • A label with ‘mx:label’
  • A button with ‘mx:button’
  • and a script block with ‘mx:script’

In the Script block you will find a public function definition which will display the popup message (button1clicked). In the mx:button tag you will see how the button event is linked to this function.

In the next blog (part III) I will implement an example where we use Google Maps in a Flex Application… could this be a candidate for the first Flash Island? And I will demonstrate how build MVC applications using Adobe Flex…

Written by MKE

December 9th, 2008 at 11:57 pm

Google Maps for Adobe AIR is now available

without comments

Google has enhanced the Google Maps API - now it wil be possible to use the API in Adobe AIR applications also. See this Google Maps tutorial.

Written by MKE

December 1st, 2008 at 11:48 pm

Posted in AIR, Adobe, Google, Maps

Tagged with ,