2014년 12월 29일 월요일

GPS & Location scensor


Hi All, I need an app to log a path on a map and log points of interest while walking. I do not have a street address to load a map but need to load a map centered on my current location which is in veld. I have not been able to get any response from my effort. Where can i get a list of the parameters I can pass to google maps to load without using an address. I have build my app and loaded it on the phone, still no response from location sensor

--

Did you try the examples from the tutorials? Did they work? Is your phone set to enable GPS?
Or maybe you live in a country where the decimal separator is a , (comma)? In that case you must convert coordinates to use . instead. Search and you will find solution by others who have had the same problems. 
If all the above cannot solve your problem, please post a screenshot of relevant blocks of what you tried.

--
You can use latitude and longitude.  This is not difficult and if you post a copy of the blocks you are attempting to use, we can probably explain why you are not .   What you want to do is to post pins or markers on the map?    You can do that with a Google Static Map (you can not do that with an ordinary google map).

A second way of doing this is to use a Fusion Table Map....Here is a Fusion Table solution and mini-tutorial with AI2:  Pin Buttons on Google Maps     To do this, you have to have an Internet or network connection.

Are either of these what you need?

If not, there are ways of using your own map that are more complicated.

--
Hi Ghica. I did work thru / copy tutorials, Phone has GPS on (other apps work) 
. I dont think I have the,. problem (South Africa). Nothing has worked. No response not even garbage.
From the blocks you will see When app is loaded this is what I need to happen
 No clock and no GPS
Start Button pressed Start clock and GPS
At every change of location I want to log & Display the data
At every change in status I want to also log/display the data
NB I have not shown the display & Log blocks, they are fine

What am I doing wrong

--
I would enable the location sensor from the beginning
also make sure to set the provider name to gps (in case it is available in the available providers list), this will take a few seconds...
also lock the provider to get better results

how does your Display procedure look like?
you should call that procedure in the LocationSensor.LocationChanged event
btw. why do you need all these global variables?

--
When you set your Clock interval to 1000, what do you think you are doing?   You are setting the clock to 1000ms.  That fires every second.  Sounds good. :)   No, it is not. :(   Why?  Because you are giving your Android and GPS receiver an electronic heart attack.   The GPS receiver requires generally five to twenty seconds to acquire a satellite fix.   Just about the time it starts to get the fix, you ask the app to get another fix, and another, and another.

Have you done the LocationSensor Tutorial?  One of the examples does part of what you want to do ... look here  http://appinventor.mit.edu/explore/ai2/tutorials3818.html?&page=2 

At every change in status, you want to display the data.... not going to happen with your code and depending on how you code the blocks you do not show, impossible.

--
Hi all, Thanx for the advice, I think it is back to school for a while. I loaded the "Where is my car " app and it did not work so I may have a hardware problem
NB in the writeup for Where is my car at the end under variations what I want is mentioned. I want to walk thru the bushveld with (upto 5 others) looking for endangered plants, mark the spot with comment and pic plotting the route to see where others are and what areas have not been covered yet as data is plotted on map

--
I noticed this in Wikipedia (not a very reliable source,however) which states that South Africa (if that is where you are Boet) uses a comma decimal separator.  

Are you converting the LocationSensor readings to accomodate the fact the sensor reports using a period (.), not a comma?  If you in an area where the decimal point separator is a period or a comma;    that is, do you write numbers like   123.456    or  123,456?  If this is the case, be aware the LocationSensor reports latitude and longitude only in this format 123.456 so you will have to replace the periods  with a comma for whatever routine you might be using.

Most AI2 users who can not get where is my car running failed to convert the decimal separator Boet.   You probably do not have a hardware problem.

The Where's My Car tutorial does not explain how to handle that when the decimal separator is a comma, as is used in most of Europe and some other places outside of North America.

We get a lot of questions about Where is My Car tutorial.(  https://groups.google.com/forum/#!searchin/mitappinventortest/where$20is$20my$20car  )  The tutorial is USA centric and does not address how the Location.Sensor coordinates are output .  The Location.Sensor Lat/Lon cordinates use a period decimal separator.   In Europe and other regions, a comma is used as a separator.   Herve's French tutorial makes it very clear what Europeans and others need to do to get the tutorial working in their environment because he specifically shows where the decimal separator needs to be converted to a comma and how to do it.


Until David Wolber updates his tutorial for the World audience ( Android, Where's My Car? for App Inventor 2  )  Herve's supplement works.
See Herrve's pdf here: app where is my car    the pdf is in the second to last post in that thread.

Did this help?

--
Hi Steve, Thanx 4 the info. What u read is true but in the data processing arena it generally not a problem. What leads me to think I have a hware problem is about a year ago I loaded Where is my car and it worked without change. I then unloaded it and tried my own version which did not work.What I find strange is that I get ZIP Zoero Nothing from any variable associated with GPS/location. I would have expected at least garbage from the attempt to use GPS. I have also changed the constants u mentioned. 1 and 1000 to 10 and 30000, still nothing.. I will keep at it

--
as already mentioned your example will not work like this


I would enable the location sensor from the beginning
also make sure to set the provider name to gps (in case it is available in the available providers list), this will take a few seconds...
also lock the provider to get better results 


how does your Display procedure look like?
you should call that procedure in the LocationSensor.LocationChanged event
btw. why do you need all these global variables?


fix the issues and try again
it also helps to change your location to be able to get a gps signal (going outside or going to the window might help)

--
Your code is most probably the issue.  Not the hardware.  You are mis-using  
DistanceInterval      1) you set it to 1, that attempts to change the satilite fix every one meter...  Read about 'Accuracy' to understand why doing that is inappropriate; 2) you also are refreshing the sensor using TimeInterval and when you use LocationSensor.Enabled to true you command the gps to do another fix ... all this is done inside a Clock control that recycles every second.

I will say this again, you are attempting to refeshing the gps every second, in two different ways and also by using a different method (DistanceInterval).

You say "What I find strange is that I get ZIP Zoero Nothing from any variable associated with GPS/location"   Don't you think the above is the reason?

Be aware, if the LocationSensor does not have a satellite fix, the sensor yields 0,0.

Your project will start to work when you get rid of your clock component, at least temporarily. You could enable the sensor from the Screen1.Initialize ...as Taifun recommends.   I do not recommend that for lots of reasons.   Yes it can work that way, however there are reasons that is not always the way your app should perform, so a START button does make sense.   Also, you do not have to set a provider list if you are going to only use gps.  There are reasons a developer would not, so if you only want to use, GPS, set LocationSensor.Provider to  gps  and forget about other methods.

Oh, well, good luck.

--
You could enable the sensor from the Screen1.Initialize ...as Taifun recommends.   I do not recommend that for lots of reasons.   Yes it can work that way, however there are reasons that is not always the way your app should perform, so a START button does make sense.  

@SteveJG: can you elaborate on these reasons? What does that mean "that is not always the way your app should perform"?
as we know, it takes a few seconds until the GPS signal is available, so if the sensor is enabled from the beginning, you will save some seconds and you will get the first signal earlier

Also, you do not have to set a provider list if you are going to only use gps.  There are reasons a developer would not, so if you only want to use, GPS, set LocationSensor.Provider to  gps  and forget about other methods.

GPS could be deactivated by the user, which means, it only makes sense to set LocationSensor.Provider to gps, if gps is available in the LocationSensor.AvailableProviders list...

--

댓글 없음:

댓글 쓰기