Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • IBM Digital Experience wiki
  • All Wikis
  • All Forums
  • ANNOUNCEMENT: WIKI CHANGE TO READ-ONLY. LEARN MORE...
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
  • API Documentation
Search
Community Articles > IBM Accelerators for WebSphere Portal > IBM Mobile Portal Accelerator > GPS (HTML5) Sample Mobile Portlet using XDIME
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

Click to view profileIBM contributorVinod Appajanna
Contribution Summary:
  • Articles authored: 4
  • Articles edited: 1
  • Comments Posted: 0

Recent articles by this author

GPS (HTML5) Sample Mobile Portlet using XDIME

This aritcle describes about how to develop a GPS sample (HTML5) portlet that can be rendered on MPA

XDIME enabled Sample Personalization Demo Portlets

The samples provided with article provides an extension to YourCo User Info, YourCo General News, YourCo General News Details, YourCo Internal News, YourCo Products, YourCo Promotions, YourCo Offer Banner, YourCo Offers and YourCo Services portlets (that are shipped with WebSphere Portal base ...

Device (Mobile) Attribute Based Personalization using MPA

In this tutorial, we extend the capabilities of Websphere Portal attribute based personalization to a mobile device using MPA. A device has numerous propertiesattribute and based on these propertiesattributes values we can apply rules, that is we can decide to show or hide a portlet or page. ...

How-To use a web service with MPA

This article will show how to create a simple webservice and how to call the same from a Mobile portlet code
Community articleGPS (HTML5) Sample Mobile Portlet using XDIME
Added by IBM contributorVinod Appajanna | Edited by IBM contributorVinod Appajanna on July 8, 2011 | Version 9
  • Edit
  • More Actions Show Menu▼
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars
expanded Abstract
collapsed Abstract
This aritcle describes about how to develop a GPS sample (HTML5) portlet that can be rendered on MPA
Tags: mobile, mobile portal WEMP UI design, Mobile MPA, Mobile portal Toolkit, Mobile Portal, Mobile Portal Accelarator, Mobile Portal Accelerator, MPA, MPA iPhone Mobile, MPA Mobile, Web 2.0, XDIME
ShowTable of Contents
HideTable of Contents
  • 1 Introduction
  • 2 Prerequisites
  • 3 Sample Description or Technical Overview
    • 3.1 Script component
    • 3.2 JSP Code
  • 4 Things to be noted
  • 5 GPS Sample (Portlet) Screen Shots
    • 5.1 Screen 1 (Using UserAgent)
    • 5.2 Screen 2 (Using Simulator)

Introduction


About MPA:

Mobile Portal Accelerator (MPA), based on device-independency, enables providers to create Web-based applications to a limitless range of mobile devices. It helps extend the capabilities of WebSphere Portal to mobile devices through device-independent Web authoring for virtually any mobile device. It uses a device independent markup language called XML-based Device Independent Markup Extensions (XDIME). Using Windows Media Services users can broadcast live or pre recorded video to mobile devices.


The recent months have seen an explosion in the market for smartphones. Smartphone sales have risen dramatically, with consumers snapping up the latest models as the smartphone vendors compete to provide the best & UI rich products with the newest technology. In this market, those consumers - your customers and employees - increasingly expect to be able to do many of the same things (including rich UI) on their mobile devices that they've traditionally done on their laptop or desktop devices.

Given this trend, technology organizations are under pressure to quickly deliver mobile web application on smartphones that are rich in UI. The introduction of the HTML5/CSS3 has provided new features (that are implemented in the browser-inbuilt) that can be leveraged in building rich mobile web applications (rendered on browsers) that are smartphone-optimized. Also since the features are based on HTML, CSS and JavaScript this helps HTML5 to be device independent.

This Article/Sample (MPA Mobile Portlet) uses HTML5 Gelocation API to get the geolocations (latitude and longitude) information of the current place and the same info is used in displaying (pin pointing) the current location (graphically) in a map form using OpenStreetMap. Note: OpenStreetMap is an open source initiative that offers similar technology as that of Google Maps


Prerequisites


This article requires the following development environment:

Mobile Portal Accelerator 7.0.1
Mobile Portal Toolkit 7.0.1
Rational Application Developer (RAD) 8.0

To test XDIME portlets, mobile simulators can be used. This article used User-Agent-Switcher to test this functionality. The sample should work in HTML5 based browsers on devices like Android, iPhone, iPod touch and iPad. Currently this has been tested on Firefox 3.6 and chrome 11.

Sample Description or Technical Overview


The sample has the following things:

Script component


This includes the OpenStreet JS file to display the MAP for the current location

JSP Code


This basically does the following things:

(a) Below code shows the usage of HTML Gelocation API's to get the current locations latitude and longitude.


if (navigator.geolocation) {
	navigator.geolocation.getCurrentPosition(displayMap, gpsError); // calls the callback method displayMap
} else {
	gpsError('not supported');
}

function displayMap(position) {
	var lat = position.coords.latitude; //gets the latitude
	var longi = position.coords.longitude; //gets the longitude
	......
}


(b) Below code shows the usage of the OpenStreet MAP API to display the MAP for the fetched latitude and longitude in the above step.


	longi = position.coords.longitude;
	lat =  position.coords.longitude;
	map = new OpenLayers.Map("basicMap");
	mapnik = new OpenLayers.Layer.OSM();
	map.addLayer(mapnik);

	lonLat = new OpenLayers.LonLat(longi,lat).transform(new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject());

	markers = new OpenLayers.Layer.Markers("Markers");
	map.addLayer(markers);
	markers.addMarker(new OpenLayers.Marker(lonLat)); // adds the marker at the current location
	map.setCenter(lonLat, 14 // Zoom level); // Center of the map


Things to be noted


(a) In order to make this sample work on MPA 7.0. Comment out "" in xdime/GeoLocationXDIME2SamplePortletView.jsp
(b) Before trying the sample make sure that the browser supports HTML5/Geolocation.
(c) You need to share your location (i.e For example in Mozilla Firefox, calling the getCurrentPosition() function of the geolocation API will cause the browser to pop up an “infobar” at the top of the browser window) with the server in order for GeoLocation API to work.

Image could not be displayed

(c) Please ensure the script related properties are set accordingly (as per the below figure) in device repository. (for example: device repo can be found under: \PortalServer\wp.mobile\wp.mobile.mcs\repository\xml-repository\devices.mdpr)




GPS Sample (Portlet) Screen Shots


Screen 1 (Using UserAgent)




Screen 2 (Using Simulator)



  • Edit
  • More Actions Show Menu▼


expanded Attachments (1)
collapsed Attachments (1)
Edit the article to add or modify attachments.
File TypeSizeFile NameCreated OnDelete file
application/octet-stream 8 KB GeoLocationXDIME2Sample.war 4/26/11, 3:21 AM
expanded Versions (9)
collapsed Versions (9)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (9)Jul 8, 2011, 4:20:57 AMVinod Appajanna  IBM contributor
8Jun 20, 2011, 1:44:32 AMVinod Appajanna  IBM contributor
7May 9, 2011, 12:16:24 PMVinod Appajanna  IBM contributor
6May 9, 2011, 12:07:00 PMVinod Appajanna  IBM contributor
4May 9, 2011, 11:59:29 AMVinod Appajanna  IBM contributor
3May 9, 2011, 8:10:54 AMVinod Appajanna  IBM contributor
2May 9, 2011, 7:44:31 AMVinod Appajanna  IBM contributor
1May 4, 2011, 3:28:33 AMVinod Appajanna  IBM contributor
1May 4, 2011, 3:34:55 AMVinod Appajanna  IBM contributor
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • FacebookIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkThe Social Lounge
  • Wiki Help
  • Forgot user name/password
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use