Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Geolocation Co-ordiantes in webview, possible?

$
0
0

Hi, i have an applicaiton which automatically finds the users current position on a map view (marked with a marker)

location.js

var win = Ti.UI.createWindow();
win.openedflag = 0;
 
Ti.Geolocation.preferredProvider = "gps";
var result;
//var locationAdded = false;
 
//SHOW CUSTOM ALERT IF DEVICE HAS GEO TURNED OFF
if (Titanium.Geolocation.locationServicesEnabled === false) {
    Titanium.UI.createAlertDialog({
        title : 'Social Prox',
        message : 'Your device has geo turned off - turn it on.'
    }).show();
}
 
//when window launches event find user  coordinates
win.addEventListener('open', function() {
 
 
    Titanium.Geolocation.getCurrentPosition(function(e) {
        if (!e.success || e.error) {
            Ti.API.info("Code translation: " + translateErrorCode(e.code));
            alert('error ' + JSON.stringify(e.error));
            return;
 
        }
 
        Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
        Titanium.Geolocation.distanceFilter = 10;
 
        var longitude = e.coords.longitude;
        var latitude = e.coords.latitude;
 
        Titanium.API.info('geo - current location: ' + ' long ' + longitude + ' lat ' + latitude);
 
        var map = Ti.Map.createView({
            mapType : Titanium.Map.STANDARD_TYPE,
            region : {
                longitude : e.coords.longitude,
                latitude : e.coords.latitude,
                latitudeDelta : 0.5,
                longitudeDelta : 0.5,
            },
            regionFit : true,
            animate : true,
        });
 
        var userLoc = Titanium.Map.createAnnotation({
            latitude : e.coords.latitude,
            longitude : e.coords.longitude,
            title : 'Your Location',
            subtitle : 'geo - current location: ' + ' long ' + longitude + ' lat ' + latitude,
            animate : true,
            //image : "marker.png"
        });
        map.addAnnotation(userLoc);
        win.add(map);
    });
 
});
 
win.open();
I also have a webview component which will post information from the mobile client to a remote server.

profile.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
 
        <meta name="viewport" content="width=device-width; initial-scale=1.0" />
        <h1> Log In Page</h1>
    </head>
    <body>
        <form action="http://130.206.127.43:8080/CreateProfile" method="post">
            First Name:
            <br>
            <input type="text" name="first_name">
            <br>
            Last Name:
            <br>
            <input type="text" name="last_name" />
            <br>
 
 
            <!---------     HOW CAN I GET GEO CO-ORDS FROM LOCATION.JS HERE?    !-->
            Longitude:
            <br>
            <input type="text" name="long" />
            Latitude:
            <input type="text" name="long" />
            <br>
            <input type="submit" value="Submit" />
        </form>
    </body>
</html>

Q1) is it possible to get the Geo co-ordinates from location.js into the webview and send them to the remote server along with users name etc?

Q2) side question if there are any web devs out there what html form type is best for long/lat my mysql database is set up for DECIMAL(10, 8) for them?

Thanks!!


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>