Permalink
Browse files

Updated version of JSLA

  • Loading branch information...
1 parent b772bd6 commit 3ec2d9633138df997aaadf06d6d606cea00edcca @mmarcon committed Apr 21, 2013

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -287,7 +287,7 @@
click: function(e){
$(this).jHERE('bubble', [52.49, 13.39], {content: JSON.stringify(e.geo), closable: false});
}}).jHERE('heatmap', heatMapData, 'value');
- $('#map').jHERE('kml', 'resources/berlin.kml', true);
+ $('#map').jHERE('kml', 'resources/berlin.kml', true).jHERE('marker', {latitude: 52.5113748680947, longitude: 13.401589126700173}, {icon: 'resources/balloon.png', anchor: {x: 24, y: 48}});
});
</script>
</body>
View
@@ -69,7 +69,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//`marker` is an object containing the same options used for
//`$('.selector').jHERE('marker')`. Options apply to both start and destionation markers.
route = function(from, to, options){
- var router, wp, done;
+ var router, wp, done, cleanOptions;
_ns = _ns || nokia.maps;
from = normalize(from);
to = normalize(to);
@@ -133,8 +133,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
wp.addCoordinate(from);
wp.addCoordinate(to);
- options.transportModes = [options.transportMode];
- router.calculateRoute(wp, [options]);
+ /*Fix for insanity*/
+ cleanOptions = {
+ transportModes: [options.transportMode],
+ type: options.type,
+ options: options.options,
+ trafficMode: options.trafficMode
+ };
+
+ router.calculateRoute(wp, [cleanOptions]);
};
$.jHERE.extend('route', route);
View
@@ -61,10 +61,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//**Note that jHERE requires Zepto.JS, jQuery > 1.7 or Tire.js >= 1.1.1**
var plugin = 'jHERE',
- defaults, H, _ns, _ns_map, _JSLALoader,
+ defaults, H, _nokia, _ns, _ns_map, _JSLALoader,
_credentials, bind = $.proxy, P,
/*Map and marker supported events*/
mouse = 'mouse', click = 'click', drag = 'drag', touch = 'touch', start = 'start', end = 'end', move = 'move',
+ appIdKey = 'appId', authTokenKey = 'authenticationToken',
supportedEvents = [
click,
'dbl' + click,
@@ -177,8 +178,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
function jHERE(element, options){
this.element = element;
this.options = $.extend({}, defaults, options);
- this._defaults = defaults;
- this._plugin = plugin;
this.init();
}
@@ -192,11 +191,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//to `$('.selector').jHERE(options);`.
P.defaultCredentials = function(appId, authToken) {
_credentials = {
- appId: appId,
- authenticationToken: authToken
+ id: appId,
+ token: authToken
};
_JSLALoader.load().is.done(function(){
- _ns.util.ApplicationContext.set(_credentials);
+ _nokia.Settings.set(appIdKey, appId);
+ _nokia.Settings.set(authTokenKey, authToken);
});
};
@@ -221,10 +221,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*First of all sort out the credential thingy*/
_credentials = _credentials || {
- appId: options.appId,
- authenticationToken: options.authToken
+ id: options.appId,
+ token: options.authToken
};
- _ns.util.ApplicationContext.set(_credentials);
+ _nokia.Settings.set(appIdKey, _credentials.id);
+ _nokia.Settings.set(authTokenKey, _credentials.token);
/*and now make the map*/
$.data(self.element, plugin, true);
@@ -657,15 +658,16 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
_JSLALoader.is = $.Deferred();
/*And load stuff*/
load = function(){
- _ns = nokia.maps;
+ _nokia = nokia;
+ _ns = _nokia.maps;
/*TODO: make load cutomizable so we don't load unnecessary stuff.*/
- _ns.Features.load({map: 'auto', ui: 'auto', search: 'auto', routing: 'auto',
+ _nokia.Features.load({map: 'auto', ui: 'auto', search: 'auto', routing: 'auto',
positioning: 'auto', behavior: 'auto', kml: 'auto', heatmap: 'auto'},
function(){_ns_map = _ns.map; _JSLALoader.is.resolve();});
};
head = doc.getElementsByTagName('head')[0];
jsla = doc.createElement('script');
- jsla.src = 'http://api.maps.nokia.com/2.2.3/jsl.js';
+ jsla.src = 'http://api.maps.nokia.com/2.2.4/jsl.js';
jsla.type = 'text/javascript';
jsla.charset = 'utf-8';
jsla.onreadystatechange = function(){
View
@@ -1,6 +1,7 @@
-P._injectNS = function(ns){
- _ns = ns;
- _ns_map = ns.map;
+P._injectNS = function(nokia){
+ _nokia = nokia;
+ _ns = nokia.maps;
+ _ns_map = _ns.map;
};
P._injectJSLALoader = function(loader){
_JSLALoader = loader;
View
@@ -45,10 +45,17 @@ var resetMocks, spy, nokia = {}, SPIES = {}, _JSLALoader;
};
//JSLA
+ nokia.Settings = {
+ set: spy('nokia.Settings.set')
+ };
+
nokia.maps = {
util: {
ApplicationContext: {
- set: spy('ApplicationContext.set')
+ set: function(){
+ console.log('ApplicationContext.set is deprecated');
+ spy('ApplicationContext.set')();
+ }
}
}
};
@@ -207,7 +214,7 @@ var resetMocks, spy, nokia = {}, SPIES = {}, _JSLALoader;
this.addData = function(){ SPIES.heatmap_addData.apply(this, arguments); };
};
- $.jHERE._injectNS(nokia.maps);
+ $.jHERE._injectNS(nokia);
$.jHERE._injectJSLALoader(_JSLALoader);
};
View
@@ -61,6 +61,12 @@ describe('jHERE', function(){
expect($('#map').data('jHERE')).toBe(true);
expect($('#map').data('plg_jHERE').mtype).toBe('map');
+ expect(nokia.Settings.set.callCount).toBe(2);
+ expect(nokia.Settings.set.argsForCall[0][0]).toBe('appId');
+ expect(nokia.Settings.set.argsForCall[0][1]).toBe('monkey');
+ expect(nokia.Settings.set.argsForCall[1][0]).toBe('authenticationToken');
+ expect(nokia.Settings.set.argsForCall[1][1]).toBe('chimpanzee');
+
expect(nokia.maps.map.component.Behavior).toHaveBeenCalled();
expect(nokia.maps.map.Display).toHaveBeenCalledWith($('#map')[0], jasmine.any(Object));
expect(nokia.maps.map.Container).toHaveBeenCalled();

0 comments on commit 3ec2d96

Please sign in to comment.