Quantcast
Channel: SCN : All Content - SAP BusinessObjects Design Studio
Viewing all articles
Browse latest Browse all 4216

Design Studio SDK: A (first) try to get an Open Street Map into Design Studio

$
0
0

Based on the blog posted by Jeroen van der A on the inclusion of open source I have made a try to get some open street map into design studio. Here the first findings...

 

Does it work?

Yes, the good point is, this works. I had to switch back again to "DIV" based component model as the map API which I use (Modest Maps | Home) requires a div which is building a parent for the component. And I think SAPUI5 has some bug as the sizing of the HTML component is not working as expected - technically there is some DIV inbetween which has no real size.So for me a bit drawback in the API as the "DIV" api is a bit different and I cannot use the metadata property.

 

Show Case (Animated GIF - click to animate)

20141027-210226_capture.gif

 

What is IN / What is not IN?

I had to learn that data SDK does not push yet attibutes of members to the client. And my test data source has the GOE-Attributes maintained as attributes on dimension CUSTOMER.

 

in release 1.4 lucky I have found a method which helps me to get the attributes in scripting. This means this component is not data based, but via "manual" scripting we can use it...

 

Here the code you need to use in order to dynamically add locations.

 

// insert madrit and SAP Headquaters in Walldorf
OSMAP_1.addLocation("MADRIT", "Madrit", "", 40.4, -3.7);
OSMAP_1.addLocation("WALLDORF", "SAP SE Headquaters", "SAP.jpg", 49.293417, 8.642384);

 

Example for 1.4 release:

 

var mem = CROSSTAB_1.getSelectedMember("0D_CUSTOMER");
// get attributes
var lat = mem.getAttributeMember("0LATITUDE");
var lon = mem.getAttributeMember("0LONGITUDE");
// calculate values
var latValue = lat.internalKey;
var lonValue = lon.internalKey;
// check if negative (as - is at the end and cannot be casted)
var latNegative = false;
var lonNegative = false;
if(latValue.indexOf("-")) {  latValue = latValue.substring(0, latValue.length -1);  latNegative = true;
}
if(lonValue.indexOf("-")) {  lonValue = lonValue.substring(0, lonValue.length -1);  lonNegative = true;
}
// convert to float after - is cut
var latValueFloat = Convert.stringToFloat(latValue);
var lonValueFloat = Convert.stringToFloat(lonValue);
// korrections as we have dummy data (only for the demo query)
latValueFloat = latValueFloat - 40;
lonValueFloat = lonValueFloat - 18;
// fix again the negative numbers
if(latNegative) {  latValueFloat = latValueFloat * -1;
}
if(lonNegative) {  lonValueFloat = lonValueFloat * -1;
}
// get the key and text from member
var key = mem.internalKey;
var tex = mem.text;
// add location (in 1.3 you need to make it in the startup of by hard coded coordinates)
OSMAP_1.addLocation(key, tex, key + ".jpg", latValueFloat, lonValueFloat);
// move map to the location
OSMAP_1.moveTo(key);

 

Available Properties

 

Property NameDescription
defaultImage

the image which should be visible if value-picture not exist (must be maintained!)

 

Scripting Functions

 

ScriptsShort Description
String getSelectedKey ()returns the selected key

void addLocation (

  /**Element Key (must be unique)*/String elementKey,

  /**Element text*/String elementText,

  /**Image URL, if not set, no image*/String imageUrl,

  /**Latitude (horizontal)*/float latitude,

  /**Longitide (vertical)*/float longitude

  )

adds location to the map which can be used later for navigation

void moveTo (

  /**key which schould be moved to*/String key)

moves map to the given location by its key
void panUp()moves the map up
void panDown()moves the map down
void panLeft()moves the map left
void panRight()moves the map right
void zoomIn()

zooms in

void zoomOut()zooms out

 

Events

 

EventShort Description
onSelectionChangedEvent triggered when selection has cahnged

 

Summary

First Step to get a map is done, as next I try to play around with different map layers and perhaps some value painting on the map (assuming SDK will be improved for the attributes)

 

Example Application

An Application with example can be downloaded at the BIAPP Repository (name SDK_OSMAP):

Releases

 

Source Code & Licensing

This component is for free use. It is under the Open Source Apache Version 2.0 License.

 

Important MaintenanceNotice (... as I am SAP Employee)

The component is NOT delivered under SAP maintenance license.

You cannot claim any Support on this component from SAP!


The components are created on "private" basis - you can use them as is. I can modify, correct or improve - but there is no obligation to do it. Of course I will try to correct bugs or improve the component as long I can.

 

Have Fun!

 

for other components see: Karol's SDK Components or Karol's SDK Data Bound Components


Viewing all articles
Browse latest Browse all 4216

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>