Thank you, I'll give it a shot.
Oh, I think I've realized my issue. I'm trying to create an app that allows the user to input a zip code. My issue isn't finding out what that latitude and longitude for that given zip code is. It's figuring out how I can get the code to pull the user's zip code from a different screen and then apply it to the map to present the user with a map of their location. If needed I can move the zip code enter box to the page with the map to prevent having to store the data over multiple screens because that seems like it might be difficult.
As I said, it is up to you where you get the lat/lon (on which screen), remember you need to give time for the locationSensor to get working.
I would also suggest you use the CentreToString when setting the coordinates, PanTo can give some strange results.
You might also consider if there is any real need to do it on separate screens at all ? Consider using virtual screens ?
I didn't know what a virtual screen was. How does that work? Is ready the description with a button and arrangements. Is the point of that to add invisible data to a screen?
I'm very new to this if you couldn't tell. Trying to get a better hang of it to complete an assignment I have for a class.
See tip 1 here
Taifun
You are using the wrong tool if you use a zip code to determine where someone is located on a map tool. Zip codes outline areas where a postal code in effect. In most places the Zip code includes all addresses within this area. A location based ONLY on a zip code database can not specifically tell show you were someone is located; it only will provide the latitude and longitude of the centroid of a zip code. The centroid is not necessarily someone's precise location (but might be somewhere near where they are). Are you telling us you have a List of coordinates corresponding to Zip codes in a database on the other Screen? For example, this link is a database showing the latitude/longitude for centroids of all the Zip codes in the USA.. To determine where the Zip code is, you would search the List for the Zip code you want. When you determine the coordinates of the centroid you can use a Map component or Google Maps to display a map near the zip code centroid. You can find a map of the USA Zip code actual boundary obtainable from the US Census Bureau. if you want a map showing the boundaries of the zip code in several formats.
You definitely need a data table for the zip codes, or have a really good location service active on the phone.
This is a failed attempt without a database:
location_sensor.aia (2.3 KB)
It's a failure because the geocoding service does not come close enough to the zip code boundaries if you just enter a zip code.
It does get the city right, if it's the same city where you live.
It also can't show the zip code boundaries, because the map doesn't know them nor does the location service tell you them.
No, I didn't create a list. I attempted to just have the user enters their location and then the map could pull that from a dynamic list to show them there location.
Should I create a database and then do something similar to your code ABG? I could use the list SteveJG provided me with that gives the centroids of all the zip codes in the US. However, if I can't copy it in and have to manually type it out that would be a struggle.
Should I just have the user enter their zip code or whatever location I decide to use on the same screen as the map?
This looks a little confusing to me. I'm unfamiliar with a lot of the more complex components. Still figuring out the program.
It was bang on centre of my postcode in the UK. Depends on whether close enough is good enough.
It looks like you need to do a little reading.
Is this your first project?
Which tutorials have you done?
Since you will be using the Map component, you should be familiar with the attributes and blocks of the Map component.
See
https://ai2.appinventor.mit.edu/reference/components/maps.html#Map
for all the display features for sizing and especially the Pan To block.
You will need to upload a zip code table into the Media folder in the Designer, and load a lookup table from it in Screen1.Initialize.
Then you will need to learn to do table lookups.
Here's your Comma Separated Values (CSV) table, from @SteveJG's link:
US20Codes20201320Data.txt (906.3 KB)
Here are some sample projects that load tables from the Media folder and do lookups:
This is my second project, the first one was extremely basic though. Is there any simpler way to do what I am trying to do? Did I choose an extremely complex task? II don't know lookup tables and am not completely familiar with all the map components. I will read them now.
Not in the USA; the postal codes areas are unusual shapes. You might be in the centroid of your postal code AREA
Thanks for the list
I will give all this a try in a few minutes and then get back to you guys. Thanks for the help I greatly appreciate it.
Probably you just want them to enter their address. The location sensor can figure out latitude and longitude.
Geocode converts an address into a latitude and longitude . You need a latitude and longitude to place a Map Marker on a Map using the Map control
This code does Geocoding. It determines the latitude and longitude for addresses in Google's database. All addresses are NOT in that database.
Put your address in a Text Box in the LocatioinSensor1.Geocode address empty puzzle piece and this code will provide a location that should be very close to your exact location .
Don't bother with the markers and the lines and the polygons, just stick to the map component, its centering and its size.