I am using the map component with locationsensor. If i do not set my device coordinates to center, it loads the map using the default (MIT) coordinates fast. But if i programmatically set center to my device locationsensor's coordinates, it took 2 minutes or even longer to see a map (with the marker of my location). What is going on here? cloudy day indoor? Thanks
you gave a clue
then maybe to get coordinates from wifi if too long, but map component does not seem to offer this method.
Just setup location services on your device to use wifi, this works well for me on my emulator which I just can't take outside
Have you tried this tutorial ? that shows how to use gps or wifi Using the Location Sensor
Among other things it that how to force the use of gps or wifi (if that is what your really want to do) but I expect your issue is something else.
or tried How to put my location on a map
What you describe can happen for a LOT of reasons; primarily not knowing how to use the LocationSensor and Map together. You didn't show your Blocks so it is impossible to provide specific advice.
it would be great if network/gps for location service can be decided programmatically
in location service of my device, there is no place for me to set to use only Wifi.
On my Android 12 device, under Location (which is turned on) it says:
Location may use sources like GPS, Wi-Fi, mobile networks and sensors to help estimate your device's location.
On my Android 10 device (and on my Android 7 device), under Location, there is an option for Wi-Fi and Bluetooth scanning (just called Scanning in the three dot menu), Wi-Fi scanning is ON, which can be used to improve location based services and features.
I have 10, wifi scanning on, but still slow,probably only after gps fails, it resorts to wifi?
The Using the Location Sensor tutorial explains how you can set the Provider to not use gps. You can use these Blocks:
The device will not change the service provider.
It is possible for providers to switch when the current provider is unable to provide adequate location fixes for circumstances. This is a Boolean switch; true/false. True, to prevent providers from changing.
ProviderName The current service provider.
The provider will most likely be either GPS or network.
One of the two aia files in the tutorial has an example showing how the ability to lock a Provider works.
A gps receiver using the LocationSensor can automatically switch from a precision service (gps for example) to WIFI.
As described in LocationSensor
It is possible for a device to switch service providers when the current provider is unable to provide adequate location information.
ProviderLocked is a Boolean value: true/false. Set to
true to prevent providers from changing. Set to
false to allow for automatic switching when necessary.
Thanks for the detailed information. after all, do i set lockprovider to False (it's True by default), provider to Network?
played with these settings, do not seem to help
Did you read post #4 , probably because you are dealing with other issues than related to Provider selection.
- What TimeInterval are you using? Setting TimeInterval using Blocks in the Screen1.Initalize event handler to 30000 ms works best with most devices in my experience. Leaving the default setting asks your device to update every 60 seconds.
- realize the initial satellite fix almost always takes 30 to 60 seconds depending on your environment (outside, inside an apartment away from windows etc.) subsequent LocationChanged events are more frequent (20 sec or less) depending on your gps hardware.
- centering the location on the Map can be realized two ways:
. The top way is what MIT recommends. Unfortunately PanTo is glitchy and frequently results in a delayed display from the OpenStreetsMap server. The lower method is what I use or small variations. The method is not glitchy and most often results in a quick display of the Map. Almost always more flexible than using PanTo.
- depending on how you interfaced the Map to the LocationSensor there are additional reasons you do not get the result you expect with regard to the map display. Sorry, I do not know as you did not share your Blocks.
Thanks a lot for the info. sounds the delay for the first loading of map is expected. But if I leave the center to default value (MIT), the map appears rightaway is because it does not need to get coordinates from the sensor.
The simple answer is yes. Depending on how fast your Android gps acquires a satellite fix, you might see a blue screen when the default latitude,longitude is used and points to a location in the Atlantic Ocean off Africa ( 0,0 ) depending on whether you set the PanTo coordinates to Map1.UserLatitude/Longitude or some other coordinates (the Map component provides many alternatives). How you code determines what happens.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.