2014년 11월 29일 토요일

Sort Distance In a List


i have a web database with 4 field (name, address, latitude, longitude) , now i would populate a list in appinventor retrieving those data from the database and i would order this list by distance from me (closer first). 
I have read how to import data from a webtinyDb , and it is not so hard, but could you address me to the right way/the right "logical workflow" to do what i want?
For example i don't understand where/when is the best step to order.... 

ps. I already have the algorithm to calculate distance from two point on a map

-- 

in case you are using a fusiontable, you can sort easily using the ORDER BY clause, see also SQL Reference Documentation of the Fusion Tables API.

SELECT * FROM <tableid>
ORDER BY ST_DISTANCE(<location_column>, <coordinate>) 

--
Thank you Taifun, i'm trying yo use Fusion Tables, but i have a very big deal with sharing step.
Isn't it possible to share my table with everyone after google login? Is real necessary to specify all the email address??! (or create a group)

--
If all you want to do to share your fusion table is to have other users just VIEW it, then all you need to do is allow sharing for anyone who has the url in the Fusion Table options; then provide the Fusion Table url to those you want to share.  They can view the table using their browser on their PC  or   you can code to use the WebViewer to bring up the page.

--
Could you explain me better? 
<Location_Column> should be in address or in coordinate?
<coordinate> are my actual coordinate?

How can i display in my app all the point stored in a map similar to "map of location" tab in fusion table ?

--
I found a workaround for the "everyone" sharing option... That is store my account in a variable and let the application to connect always with my login...
But i don't know how to do that...

--
@Alfo Pietro.... I do not recommend you use your workaround.  You should not share your login.


--
Could you explain me better?
<Location_Column> should be in address or in coordinate?
<coordinate> are my actual coordinate?
sorry, I never tried this, but you should be able to find some examples doing a Google search...
and yes <coordinate> is your actual coordinate

--
Thanks both...

I have one more question... i took my "Map of Location" link from the Publish button in Fusion Table. It works fine if i use the WebViewer component or if i copy/paste the link in a browser on my computer. But, if i want to use ActivityStarter to open google maps ,passing it my link, it does not show me the marker point on the map.
Maybe i should use different parameter for Activity Starter?

Action: android.intent.action.VIEW
ActivityClass: com.google.android.maps.MapsActivity
ActivityPackage: com.google.android.apps.maps

The parameter above doeasn't works.

--
that link will not work with Google Maps, you can use that link with the webviewer or alternatively you can use the activity starter to open that link with a browser

                       Open the browser to a Web page
Use these activity starter properties to open a specific web page:
Action: android.intent.action.VIEW

--
i Have a map into Vewbviewr with several marker point. What i need now is that when i click on a point, the cards opened with all the information , and a link permit me to navigate to that point..... or somethings like that... in any case i need that clicking on one point, i see the cards, and also a way to navigate to that point... like in "normal" google maps 

--
This explains what you need to do with your fusion  table....https://support.google.com/fusiontables/answer/2527132?hl=en

What you want to do is NOT easy but doable with Ai2.   Perhaps someone will give you a complete example but I doubt that.

Try some blocks; that is what programmers do.   You can set this up without using AI2 since you already have your fusion table; you just have to learn how to use the fusion table...which is not an AI2 toy.   There are examples in the Google API and on the Internet.

So many people believe EVERYTHING has to be done on the Android device.  That is just not smart thinking.   AI2 is very limited in what it can do compared to other Android compilers and what can be done with Windows.  

--
ok, thank you, just another question, i followed the "pizza party" tutorial, and i'm able to populate table and retrieve context. But i don't why if i try to do any custom query like a easy "order by name" , i receive always error. 
Could you show me the right step/blocks to do for a custom query? I can't really understand why i can't....

--

It would really help if you provided a screenshot incl. Do it result of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

--
Sorry but at the moment i'm traveling for work and i can't make screenshot.
Anyway, basically my problem is that in Pizza Party tutorial there is an Insert Statement and than a webViewer component that show all the table.
But , if i have a button with a SendQuery () command, how can i display in WebViewer the returned row only?


--
to display the result in the webviewer, you can alternatively define the SELECT statement in the URL, see also here https://plus.google.com/104335783693415100996/posts/G1NRtEuznTQ


--

댓글 없음:

댓글 쓰기