• cloud_doug
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

Hi Folks, I have a question regarding an example from the CookBook: "Retrieving a User's Location from a GPS-enabled Phone"

The issue is that I cannot get the latitude/longitude values to display on the form using an iPhone.

I'll use "longitude" as the example.  The functions look like this:

            function updateLocation(lat,lon) {
                document.getElementById('{!$Component.for.block1.longitude}').value="1.01"; /* lon; */
                document.getElementById('{!$Component.for.block1.latitude}').value="2.02";  /* lat; */
            }
            function getLocation() {
                mobileforce.device.getLocation(updateLocation);
                //work around required for Blackberry
                if (window.blackberry)
                    setInterval("getLocation()", 10000);
                    return false;
            }

 

And the apex:form like this:

    <apex:pageblock id="block1">
    Sales Visit Name: <br />
    <apex:inputField value="{!visit.name}" /><br />
    Sales Visit Description: <br />
    <apex:inputField value="{!visit.Description__c}" /><br />
    Longitude: <br />
    <apex:inputField  id="longitude" value="{!visit.Longitude__c}" /><br />
    Latitude: <br />
    <apex:inputField value="{!visit.Latitude__c}" /><br />
    <button type="button" value="GPS" onclick="getLocation();"> Get location </button>

 

On the Apex:inputfield tag for "longitude", I tried adding an "id" value but that did not appear to make a difference.

The original tutorial does not incldue this param.

What am I missing here?   I searched the forums but did not find any reference. I am sure that it is my lack of understanding JS.   thanks for any help.  -doug



 

Hi Folks, I have a question regarding an example from the CookBook: "Retrieving a User's Location from a GPS-enabled Phone"

The issue is that I cannot get the latitude/longitude values to display on the form using an iPhone.

I'll use "longitude" as the example.  The functions look like this:

            function updateLocation(lat,lon) {
                document.getElementById('{!$Component.for.block1.longitude}').value="1.01"; /* lon; */
                document.getElementById('{!$Component.for.block1.latitude}').value="2.02";  /* lat; */
            }
            function getLocation() {
                mobileforce.device.getLocation(updateLocation);
                //work around required for Blackberry
                if (window.blackberry)
                    setInterval("getLocation()", 10000);
                    return false;
            }

 

And the apex:form like this:

    <apex:pageblock id="block1">
    Sales Visit Name: <br />
    <apex:inputField value="{!visit.name}" /><br />
    Sales Visit Description: <br />
    <apex:inputField value="{!visit.Description__c}" /><br />
    Longitude: <br />
    <apex:inputField  id="longitude" value="{!visit.Longitude__c}" /><br />
    Latitude: <br />
    <apex:inputField value="{!visit.Latitude__c}" /><br />
    <button type="button" value="GPS" onclick="getLocation();"> Get location </button>

 

On the Apex:inputfield tag for "longitude", I tried adding an "id" value but that did not appear to make a difference.

The original tutorial does not incldue this param.

What am I missing here?   I searched the forums but did not find any reference. I am sure that it is my lack of understanding JS.   thanks for any help.  -doug