View Single Post
Blaizzen's Avatar
Posts: 397 | Thanked: 802 times | Joined on Jan 2010 @ Sydney
#28
Although I'm not that good at javascript either, I'll try explain what I think happens

1. Application opens up and all the important functions etc are initialised. In the "postAttach: function () {" function it creates a new instance of "GuidanceModel"
Code:
this.guidance = new nokia.maps.pfw.GuidanceModel(this._pluginControl, this.routing, this.position, this.map);
2. This creates the "GuidanceModel" with the current settings etc. Since its been created, it will run any code in the initialise section
Code:
    var GuidanceModel = new Class({
        Name: "GuidanceModel",
        Implements: [EventSource, Destroyable],
        _currentRoute: null,
        _MANEUVER_ICONS: null,
        _guidance: null,
        initialize: function (aPluginControl, aRoutingModel, aPositionModel, aMapModel) {
            var modelInstance = nokia.maps.pfw.PlayerManager.getModelInstance(aPluginControl, this.className);
            if (modelInstance) {
                return modelInstance
            } else {
                nokia.maps.pfw.PlayerManager.addModelInstance(aPluginControl, this.className, this)
            }

            this._pluginControl = aPluginControl;
            try {
                this._guidance = this._pluginControl.getGuidance();
            } catch (ex) {
                this._guidance = null
            }
            if (!this._guidance) {
                this._guidance = new GuidanceMockup();
            }
            this._guidance.setOnGuidanceDone(bind(this, this._onGuidanceDone));
            this._routeModel = aRoutingModel;
            this._mapModel = aMapModel;
            this._positionModel = aPositionModel;
		
        },
        isGuidanceSupported: function () {
            return this._guidance !== null && this._guidance !== undefined && this._guidance.className !== "GuidanceMockup"
        }, etc etc
On my desktop, since we don't have access to GPS features etc, guidance is not supported, so it sets guidance as "GuidanceMockup". This is to prevent any calls to the function from failing (at least I think so... ).

On the N900, guidance is partially supported, so it does not create an instance of "GuidanceMockup".

3. Guidance (the plugin on the N900 or the GuidanceMockup on the desktop), is by
Code:
this._pluginControl = this._page.getChildAt("plugin");
.
.
.
this.guidance = new nokia.maps.pfw.GuidanceModel(this._pluginControl, this.routing, this.position, this.map);
Now what this plugin is exactly, I'm not too sure, but I think its the atlas plugin inside MicroB (but sadly that doesn't explain why I can't open the html page from normal microB).



A little tip i figured out. I made a small textbox in the body of the html
HTML Code:
    <body>
    <textarea cols="95" rows="5" id="recmsg"></textarea>
    </body>
then a small function in the javascript (right at the top)
HTML Code:
        <script type="text/javascript" id="javascriptApplication">
try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    var cPLX = Components.classes["@nokia.com/MapsPlugin"].getService(Components.interfaces.IPlugin);
} catch (e) {
    var cPLX = null;
}


[B]//here here
function writemessage(e){
	var txt = e;
	var tbox = document.getElementById('recmsg');
	if (tbox)
	{
		tbox.value = tbox.value + "\n" + txt;
		tbox.scrollTop = tbox.scrollHeight - tbox.clientHeight;
	};
}[/B]
so anytime time in the code I want to check if something is run or messages or warnings etc, I call writemessage("blaa blaa") and it will display in the textbox. Sadly though it kinda screws up with the maps application (so the bottom is cut off), but for quick testing its helping.


Hope that explains most of it

Last edited by Blaizzen; 2010-12-23 at 09:34.