Here is how the LocationSensor works
|
| Exploring with Location Sensor in AI2 The location sensor object is used to communicate with the global positioning satellite receiver (GPS) in your phone/tablet. When the LocationSensor communicates with the built-in GPS receiver, the GPS can determine the location of your device. The sensor can also work with network/wifi location services. Finding a location using the network uses very different techniques to determine a location. Location means, the device's present latitude and longitude or it can mean your street address. |
Are you showing all your blocks? I do not see a LocationSensor.LocationChanged block in your project. Did you place a LocationSensor control on the Designer screen?
When you read Exploring with Location Sensor in AI2 there is a section on how the internal GPS on your device gets a satellite fix. When first turned on, it may take 20 to 30 seconds to get a fix. A subsequent fix will usually be possible within 5 to 10 seconds depending on your hardware and where you are located and other factors.
When first turned on, before getting a fix, the locationsensor has a default latitude/longitude of 0,0 . You know the GPS has a satellite fix when these are not zero.
To give the LocationSensor time to acquire the required satellites, you might include a Clock in your code to provide up to perhaps 30 seconds delay.
Be aware HasLongitudeLatitude
- If true, Android device can report longitude and latitude it does not mean it has a satellite fix, all it means is the device is capable of reporting latitude and longitude. To actually get a latitude/longitude yu nee to use the LocationChanged event. You should be checking whether latitude/longitude are no longer 0 0
- Hope this helps.