Geolocation in Icenium

11 posts, 0 answers
  1. mvbaffa
    mvbaffa avatar
    102 posts
    Member since:
    Dec 2006

    Posted 28 Feb 2013 Link to this post

    Hi,

    I have changed the sample-geolocation example to work in a KendoUI Mobile simple application I have developed.

    It seems to working ok on my desktop, the watchPosition gets peridically the current position and generates the onSucces event. My project works with RequireJs, KendoUI Mobile and the Kendo MVVM. Is seems OK.

    If I run on device the problems starts to happen. The main view is displayed, the first position event, generated by watchPosition, is fired, but the position events stpped to be fired. It seems that the program crashed.

    When I generate the APK and deployied it manually to my Galaxy S Beam the Icenium Splash screen is displayed and after that a white screen, no content, appears and nothing happens.

    One more thing if I export the project and build with PhoneGap Build the apk is incredibly larger, in Icenium it takes 390Kb in Phonegap Build 1.6 MB. But when I deploy the apk to the device the same thing accurs. A white View is displayed.

    Is this a known issue ? Can you help me ?

    Thanks in advance
  2. Jordan
    Admin
    Jordan avatar
    197 posts

    Posted 01 Mar 2013 Link to this post

    Hello,

    Can you help us to reproduce the issue by providing a sample that we can use to reproduce that. Maybe you can insulate the issue in single html code snippet?
     

    Greetings,
    Jordan
    the Telerik team

    Share feedback and vote for features on our Feedback Portal.
    Want some Kendo UI online training - head over to Pluralsight.
  3. mvbaffa
    mvbaffa avatar
    102 posts
    Member since:
    Dec 2006

    Posted 01 Mar 2013 Link to this post

    Hi Jordan,

    I have a Module that does collect the dataPoints with watchLocation and a ViewModel File. As soon as I can have access to my development machine send you the source file.

    The deploy on device is working, but the APK still shows a white screen.

    Thanks
  4. mvbaffa
    mvbaffa avatar
    102 posts
    Member since:
    Dec 2006

    Posted 06 Mar 2013 Link to this post

    It is very difficult in one file. If there is a way to send the zip generated by Icenium it would be better.

    Anyway this is main class that gets the geolocation:

    define("GeoLocation", ["kendo", "app/viewModel/vmHome"], function (kendo, vmHome) {
        
        var _numCollection = 1;
        
        function GeoLocation() {
            
            this._watchID = null;
            this._currPosition = {numCollection: 0, description: ""};
        };
        
        GeoLocation.prototype.run = function() {
            var that = this;
            _handleWatch.apply(that, arguments);
        };
        
        var _handleWatch = function() {
            
            var that = this;
            
            if (that._watchID != null) {
    _setResults("");
    navigator.geolocation.clearWatch(that._watchID);
    //that._watchID = null;
                _setResults("Start Geolocation Watch");
    }
    else {
    _setResults("Waiting for geolocation information...");
    // Update the watch every second.
    var options = {
    maximumAge:10000, timeout:10000,
    enableHighAccuracy: true
    };
    that._watchID = navigator.geolocation.watchPosition(function() {
    _onSuccess.apply(that, arguments);
    }, function() {
    _onError.apply(that, arguments);
    }, options);
                _setResults("Clear Geolocation Watch");
    }
        };
            
        var _onSuccess = function(position) {
            
            _numCollection++;
            _setResults("Collecting Data" + ', Coleta: ' + _numCollection.toString());
            
            //var _geocoder = new GClientGeocoder();
            //var _point = new GLatLng(position.coords.latitude, position.coords.longitude);
            //_geocoder.getLocations(_point, _showAddress);
            
            var geocoder = new google.maps.Geocoder();
            var _point = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
            geocoder.geocode( {'latLng': _point}, _showAddressV3 );
        };
        
        var _showAddressV3 = function(results, status) {
            
            var _currPosition = {numCollection: 0, description: ""};
            
            if (status == google.maps.GeocoderStatus.OK) {
                if (results[1]) {
                    _currPosition.numCollection = _numCollection;
                    _currPosition.description = (_numCollection).toString() + ") " +
                                                "<b>latlng:</b>&nbsp;" + results[0].geometry.location.ib.toString() + "," + results[0].geometry.location.jb.toString() + "<br/>" +
                                                "<b>Address:</b>&nbsp;" + results[0].formatted_address;
                    vmHome.viewModel.addPoint(_currPosition); 
                    }
            } else {
                 _currPosition.numCollection = _numCollection;
                _currPosition.description = (_numCollection).toString() + ")&nbsp;" +
                                            "Error Code:" + status;
                vmHome.viewModel.addPoint(_currPosition);
            }
        }
        
        var _showAddress = function(response) {
            
            var _currPosition = {numCollection: 0, description: ""};
            
            if (!response || response.Status.code != 200) {
                _currPosition.numCollection = _numCollection;
                _currPosition.description = (_numCollection).toString() + ")&nbsp;" +
                                            "Error Code:" + response.Status.code;
                vmHome.viewModel.addPoint(_currPosition);
            } else {
                var _place = response.Placemark[0];
                _currPosition.numCollection = _numCollection;
                _currPosition.description = (_numCollection).toString() + ")&nbsp;" +
                                            "<b>latlng:</b>&nbsp;" + response.name + "<br/>" +
                                            "<b>Address:</b>&nbsp;" + _place.address;
                vmHome.viewModel.addPoint(_currPosition);
            }
        };
        
        var _onError = function(error) {

            _setResults('code: ' + error.code + '<br/>' +
    'message: ' + error.message + '<br/>');
        };
        
        var _setResults = function (value) {
            if (!value) {
    vmHome.viewModel.set("message", "");
    }
    else {
                vmHome.viewModel.set("message", value);
    }
        };

        return GeoLocation;
    });
        
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 07 Mar 2013 Link to this post

    Hello,

    Thank you for the code snippets you've provided, but we would need more than that.

    We have transferred your forum thread to our support system, so you can attach a sample we can use to replicate the problem you've encountered. Once we review it, we would be able to provide you with more information on the matter.

    Regards,
    Steve
    the Telerik team

    Share feedback and vote for features on our Feedback Portal.
    Want some Kendo UI online training - head over to Pluralsight.
  6. mvbaffa
    mvbaffa avatar
    102 posts
    Member since:
    Dec 2006

    Posted 08 Mar 2013 Link to this post

    Hi Jordan

    I am sending yoy the zip generate by Icenium Export. <FILE REMOVED BY ADMIN FOR PRIVACY>

    Thanks in advance
  7. Jordan
    Admin
    Jordan avatar
    197 posts

    Posted 13 Mar 2013 Link to this post

    <THREAD CONVERTER TO FORUM POST FOR COMMUNITY REFERENCE>

    Hello Markus,

    I just found the issue with your project the problem is that pats have to be case-sensitive and relative too. In your case it is GeoLocation with lowercase 'l'. Please rename file to be with uppercase 'L'.



    Good news is that with next release in a week or so in Mist simulator we will catch that and will return:
    ... My%20way/scripts/app/model/GeoLocation.js 404 (Mobile application path must be case-sensitive.)

    Greetings,
    Jordan
    the Telerik team

    Share feedback and vote for features on our Feedback Portal.
    Want some Kendo UI online training - head over to Pluralsight.
  8. mvbaffa
    mvbaffa avatar
    102 posts
    Member since:
    Dec 2006

    Posted 13 Mar 2013 Link to this post

    Thanks Jordan

    It worked.

    But I have two other questions:
    1) How can we treat the android back hardware button. My application has two tabs if I navigate and press the backbutton it returns to the other tab. How can I drive the back button event  to avoid this;

    2) Is there a place where I can learn how the View events work. The init event is only fired when the tab that contains the view is first opened. The events of KendoMobile are a little bit confused.

    Can you help me ???
    Thanks in advance
  9. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 14 Mar 2013 Link to this post

    Hi Markus,

    Glad we were able to narrow down the original problem. Up to your new questions:
    1. In general the back button behavior in Android is pretty much undetermined and it acts differently in different scenarios. Since you have not shared what you expect to happen, can you elaborate? You can take a look at the backbutton event docs and see if that makes any difference for your scenario.
    2. Take a look at the following articles:

    Regards,
    Steve
    the Telerik team

    Share feedback and vote for features on our Feedback Portal.
    Want some Kendo UI online training - head over to Pluralsight.
  10. mvbaffa
    mvbaffa avatar
    102 posts
    Member since:
    Dec 2006

    Posted 14 Mar 2013 Link to this post

    Thanks Steve,

    I will check it out.
  11. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 15 Mar 2013 Link to this post

    I have this in my onDeviceReady:

    document.addEventListener("backbutton", onBackKeyDown, false);



    and function onBackKeyDown:

        function onBackKeyDown() {

            if (detailPageActive == 0) {

                navigator.notification.confirm('Exit App?', onConfirmExit, '', 'No, Yes');

            }

            else {

                detailPageActive = 0;

                history.back();

            }

        }



    My app has tabs with listviews and detailpages with details of the items
    in these listviews. When a detailpage is active (value 1) then I do a
    history back and set detailpage to 0. If detailpage is already 0, then I
    know I am on a tab and the user get a confirm box which asks if I want
    to exit.



        function onConfirmExit(button) {

             navigator.app.exitApp();   

        }



    Works very well for me this way, I have this in multiple apps
Back to Top