I'm developping a mobile web site that will be accessible by blackberry devices with a built in gps receiver and i'm having some problem with some javascript i think... here is one of my page
Code:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
<% if( ( TempData["ErrorMsg"] ?? ViewData.ErrorMsg ) != null ){ %>
<p class="error">
<% =TempData["ErrorMsg"] ?? ViewData.ErrorMsg %></p>
<% } %>
<%using (Html.Form<PunchController>(p => p.GetNextView(Guid.NewGuid()), FormMethod.Post, new { _id = "formindex" }))
{ %>
<%=string.Format(GTSResources.GetLocalizedText("CurrentStateMsg"), ViewData.CurrentState)%>
<br />
<br />
<%=GTSResources.GetLocalizedText("CurrentStateChoiceMsg")%>
<%=Html.Select("DesiredState", ViewData.PossibleStateTransition)%>
<%=Html.Hidden("GpsCoordinate", null)%>
<%=Html.Hidden("PreviousPage", "Index")%>
<br />
<br />
<%=Html.SubmitButton("submit", GTSResources.GetLocalizedText("SubmitBtnText"), new { _onclick = "SetGps();"})%>
<%} %>
<script type="text/javascript">
function SetGps()
{
if(blackberry.location.GPSSupported)
{
blackberry.location.setAidMode(1);
blackberry.location.refreshLocation();
document.formindex.elements['GpsCoordinate'].value = blackberry.location.latitude + "," + blackberry.location.longitude;
}
window.alert(document.formindex.elements['GpsCoordinate'].value);
return true;
};
</script>
</asp:Content>
The problem is that the GpsCoordinate gets updated the first time only, all request after shows the same gps coordinate as previous. Would it be a problem with the javascript? I've also noticed that if a break into the server code and wait for 5 seconds before continuing, the gpsCoordinate gets updated correctly?? strange?
My second question is regarding a second application that would be running in the background on the device. I would like to record the gps coordinate every 30 seconds and send them to a web service on my server via http. Can this be achieve without using mds as my client does not have it and my provider (bell mobility) does not seem to have apn. Could i just be sending http request with this background application and use the browser for my mobile web site in the same time?
Any pointer and comment will be very appreciate.
thanks
mateo