Problem 1 : with a function for phone number , Problem2 : With geolocation

You must Login before you can answer or comment on any questions.

Hello to all you guys! I need two little help, so I avoid open two topics and ask that's all.

The first problem is this: I would like pressing a button would open the phone app with already typed the phone number to call, so I tried but does not work

var cell1 = Ti.UI.createImageView({
    image:"/images/pizza.png",
    top:20,
    left:20
});
 
cell1.addEventListener('click',function(e){
    alert("ciao");
    Titanium.Platform.openURL('tel:0844444444');
})

The second problem, but more a problem is a question: Can you tell me if theres a example that demonstrates the use of google maps in this way? : Detects the current position, and it opens the page of google maps with the starting point using the coordinates of the current position and the destination coordinates of a position pre-set

Thank you.

4 Answers

This applies to Titanium as well:

http://stackoverflow.com/questions/3760972/open-google-maps-from-iphone-and-show-route

The phone call will work on device only.

i tried this code for geolocation , but i have as a result of this error

code

var button = Titanium.UI.createButton({
   title: 'Get Directions'
});
button.addEventListener('click',function(e)
{
    if (Titanium.Geolocation.locationServicesEnabled==false)
        {
            Titanium.UI.createAlertDialog({title:'Guerrilla Website Design', message:'You need to be online to view this page.'}).show();
        }
        else
        {
                Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
                Titanium.Geolocation.distanceFilter = 10;
                Titanium.Geolocation.getCurrentPosition(function(e)
                {
 
                    if (e.error)
                    {
                        return;
                    }
                    var longitude = e.coords.longitude;
                    var latitude = e.coords.latitude;
 
                    var url = "http://maps.google.co.uk/maps?f=d&source=s_d&saddr="+latitude+","+longitude+"&daddr=guerrilla+website+design+leighton+lu7+1je&hl=en&geocode=&mra=ls&sll="+latitude+","+longitude+"&sspn=0.318051,1.056747&ie=UTF8&z=7";
Ti.Platform.openURL(url);
                    Ti.API.info(url);
 
                });
 
        }
});
Titanium.UI.currentWindow.add(button);

error

[ERROR] Script Error = 'undefined' is not an object (evaluating 'Titanium.UI.currentWindow.add') at app.js (line 32).

Hi nicolo, tel: works with phone only and for the second case Titanium.UI.currentWindow is undefined. so check code for that.

Hi nicolo, Titanium.UI.currentWindow is undefined means you must not have used url property correctly thats why you are not able to get the window object in which this view processing should be done.

Your Answer

Think you can help? Login to answer this question!