TourGuide - Virtual Sightseeing
This application is a simple application with a Spinner select a location and view that location on a MapView. Click here to download the complete source.
Here is what this TourGuide application looks like:

The main class "TourGuide" is a MapActivity. Only a MapActivity is permitted to create a MapView, but for some reason, you are not permitted to use a MapView XML element. However, I found a workaround in this post on android-developers. If you use a <MapView> element you will get an error, but if you use a <view> and separately specify the class as "com.google.android.maps.MapVi
Here is the main.xml layout file that we'll use for this application:
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.c
om/apk/res/android" - android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <view class="com.google.android.maps.
MapView" - android:id="@+id/map"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"/>
- <Spinner android:id="@+id/spinner1"
- android:layout_alignParentTop="true"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:drawSelectorOnTop="true"
- android:paddingTop="10dip"
- android:paddingBottom="10dip" />
- </RelativeLayout>
Our layout is a RelativeLayout with a MapView that fills the whole screen, and a spinner floating on top of it at the top of the screen. Now we must create our MapActivity in TourGuide.java:
- public class TourGuide extends MapActivity {
- { "Bill Gates' house", "-122.242135,47.627787&qu
ot; }, - { "Shepshed Dynamo Football Grounds", "-1.286913,52.774472"
; }, - { "Michael Jackson's Neverland Ranch", "-120.088012,34.745527&qu
ot; }, - { "Leaning Tower of Pisa", "10.396473,43.723002"
; }, - { "Airplane Graveyard", "-110.834026,32.150899&qu
ot; }, - { "Grand Canyon", "-112.298641,36.142788&qu
ot; }, - { "Lake Kariba", "27.990417,-17.235252&quo
t; }, - { "White House", "-77.036519,38.897605&quo
t; }, - { "World Trade Center site", "-74.012253,40.711641&quo
t; }, - { "Las Vegas Strip", "-115.162296,36.133347&qu
ot; } }; - private Spinner spinner;
- private MapView map;
- private MapController mc;
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- spinner = (Spinner) this.findViewById(R.id.spinner1);
- map = (MapView) findViewById(R.id.map);
- mc = map.getController();
- ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(
- this, android.R.layout.simple_spinner_dropdown_item);
- for (int i = 0; i < locations.length; i++)
- adapter.addObject(locations[i][0]);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- spinner.setAdapter(adapter);
- spinner.setOnItemSelectedListener(selectListener);
- gotoSelected();
- }
- private OnItemSelectedListener selectListener = new OnItemSelectedListener() {
- gotoSelected();
- }
- public void onNothingSelected(AdapterView arg0) {}
- };
So first I've just defined an array of Strings called location starting on line 18. It's a 2d array with each entry having the label for the location and the latitude/longitude. I grabbed these from http://www.satellite-sightseer
In the onCreate() function we first initialize our MapView and Spinner. After that we create an ArrayAdapter to use with the Spinner and add each label from the locations array to this ArrayAdapter. Once it's filled in we set it as the ArrayAdapter for the Spinner and then call gotoSelected() to move the map to the currently selected item (Area 51 when you first start this app in this example). Finally we setup the Spinner's OnItemSelectdListener so that it will call gotoSelected() when a new item is selected.
Here is the gotoSelected() function that will move our map to the correct location:
- public void gotoSelected() {
- int pos = spinner.getSelectedItemPosition();
- mc.animateTo(p);
- mc.zoomTo(18);
- if (!map.isSatellite())
- map.toggleSatellite();
- map.invalidate();
- }
To go to a location we must create a Point using the latitude and longitude in microdegrees (10^-6). So we get the coordinates from the locations array string for the selected object and split it to get the seperate longitude and latitude as a double. Once we have these we must multiply each one by 1,000,000 to get it's value in microdegrees. Now that we have the Point object we can use a MapController to go to our point using animateTo(Point) and a zoom level of 18 using zoomTo(Int). Finally we make sure that we are showing satellite view instead of map view, and we call map.invalidate() to force it to redraw.
With this you would be able to go view different objects and pan around using the touchscreen. But pressing "I" or "O" doesn't zoom like it normally does, so we must handle those keys to allow the user to zoom in and out. We can simply override the onKeyDown function, and here is that function:
Very simple switch statement here, if the user pressed "I" we zoom in, and they press "O" we zoom out.
I hope you enjoyed this simple application to demonstrate using a MapView. Obviously it's not ideal to just have a bunch of hard-coded locations, but it could be extended to pull and parse some XML from a source on the internet or could be populated by performing a Search on keywords. If you have any questions/comments/suggestions
Good luck in the challenge!!
New tutorials from Helloandroid
Recent Apps
Android on Twitter
-
@619Apps (iPhone App Developer)'Xperia Sola' trademark hints at another possible Sony handset for the U.S. - http://t.co/atxhdfFz #iPhone #android #apps
3 hours 35 min ago -
@ayakaarchdia233 (Love)I've just received an achievement: Discriminating Shopper https://t.co/LDVOSV6I #Android #Androidgames
3 hours 35 min ago -
@DevrynBluelagon (Devryn Bluelagon)I've just received an achievement: Novice Photographer https://t.co/NpjOoveN #Android #Androidgames
3 hours 35 min ago -
@games_lma (leila marie ashley)I've just received an achievement: Persistent Shopper https://t.co/vTs6DSor #Android #Androidgames
3 hours 35 min ago -
@hawkhugh (hawkhugh)Apple's iPad3 http://t.co/T9dSUJA9 #apple #ipad3 #iphone #android
3 hours 35 min ago
Poll
Useful resources
Android Development Projects
- Tourist guide for Android and IPHONE need by Denakom
- Android App: GPS: Form: Database: Website by danishayubb
- Jquery Mobile Project 01 by menfirst
- Simple Android App to load our Mobile Site - Hiring NOW! by steadysystems
- mobile app by ultimaterrrr
- android apps by vaneet08
- Online food shopping app (anroid) by akshaynawale
- Android eBook / reader Application by bamohriz
- Android app 50k downloads by nhcteam
- Beautiful Android Live Wallpaper by wahid2o11




Comments
دردشة سورية دردشة
دردشة سورية
دردشة لبنانية
دردشة عراقية
شات سوري
شات لبناني
دردشة سوريا
دردشة لبنان
شات سوريا
شات لبنان
دردشة السويدي
منتديات السويدي
اغاني عراقية
صور فنانين
الرياضة العراقية
شعراء العراق
نغمات عراقية
اغاني عربية
اغاني كردية
دردشة عراقية
دردشة بنات العراق
دردشة صبايا بغداد
دردشة البصره
دردشة بغداد
دردشة بغدادية
دردشة صبايا بغداد
دردشة شباب العراق
دردشة بنات العراق
دردشة الكرادة
دردشة دمشق
دردشة بيروت
دردشة حلب
دردشة حلب
دردشة عراقية
دردشة العراق
شات عراقي
جات عراقي
دردشه عراقيه
دردشة صبايا لبنان
دردشة بنات لبنان
شات صوتي | دردشة صوتية | كلام
شات صوتي
| دردشة صوتية
|
كلام
| شات كلام
|
دردشة كلام
| دردشة صوتية
|
شات صوتي
| شات
|
Chat Voice
| ahj w,jd
شات صوتي
| دردشة صوتية
|
شات صوتي
| دردشة صوتية
|
دردشه
| دردشة
|
صوتي
| صوتية
|
شات صوتي
| دردشة صوتية
|
شات صوتي
| دردشة صوتية
|
الكلام
| دردشه صوتيه
|
]v]am w,jdm
| ]v]ai w,jdi
شات صوتي
شات صوتي
شات صوتي
While browsing through all
While browsing through all those funny quotes on this site a thought struck my mind. How does one keep coming up with such mind boggling yet brilliant quotes. Personally I think the key is to relax and have fun with what you are doing. The good ideas tend to come when you least expect it.website optimisation
Space has become a
Space has become a battlefield ,website optimisation when the flash off when the hurricane ’s shadow and Jian spread out when nike shox back from the surprise of God , the clouds have g Jing thousand feet in an instant .
Admiring plenty of time as
Admiring plenty of time as well as you add into your blog and details you are offering! I most certainly will bookmark your website and also have my local freinds check here often. Thumbs up .
megaupload search
These advocates said that how
These advocates said that how teachers taught students and disciplined them mattered. How security guards followed children mattered. How educators placed students in classes and programs mattered. How principals responded to peer harassment mattered. How superintendents distributed resources to school buildings mattered. Like the white parents filing disability cases, parents and advocates for students of color demanded what I call everyday justice. They asked educators to provide specific students with particular additional opportunities to learn and thrive in their daily lives.
austin moving companies
It's valuable information and
It's valuable information and helpful Thank you for this add-on
العاب تلبيس
Master of Breakthrough
nice article...
by
sarang semut
very nice post
very nice post! this is very useful! thanks :)
behel lepas pasang
nice post!
very nice post! it's very useful
heavenrooms.com | 5770 benchmark
Johnsilva
My first visit to your site is been a big help.
My blog : Web Design Miami | Miami Web Design
HAVERTOWNFORJESUS.ORG - is a
HAVERTOWNFORJESUS.ORG - is a web site bonus for those bitten classic film, students, lovers of pigs and anyone interested in the great films of the last century. Media Engine Detailed synopsis plot, comments and reference review of the film are some of the functionalities available for the site.Media Search Engines The site also contains the analysis of movies, original content, information on the best films and most memorable movie scenes, the "best of" articles, and citations of the most popular film in all genres of films
great
thanks for your article its really great and useful
sportbike specifications SKEMA RANGKAIAN Electronic Circuit scolarship wireless car specifications gadget and computer car first look Motorcycle Modification sexi-stars. newlaptop circuits-audio electronic projects auto girl weapons system science kids gadget bikes walpaper mobil-wallpaper MODIFIKASI MOBIL plane-wallpaper celebsexypict artist-scandal sport-cars bikespict motor-modify sexi-model laptopharga gambar-artist fast-superbike autoshowmodel harga-kamera notebook-price diamonds-collections phones-gallery camera-prices home-pic audio-gallery autocarpict living-cares homes life-style
MapView
The main class "TourGuide" is a MapActivity. Only a MapActivity is permitted to create a MapView, but for some reason, you are not permitted to use a MapView XML element. However, I found a workaround in this post on android-developers.
Concesionarios Audi
really great
thanks for your article its really great and useful
sportbike specifications SKEMA RANGKAIAN Electronic Circuit scolarship wireless car specifications gadget and computer car first look Motorcycle Modification sexi-stars. newlaptop circuits-audio electronic projects auto girl weapons system science kids gadget bikes walpaper mobil-wallpaper MODIFIKASI MOBIL plane-wallpaper celebsexypict artist-scandal sport-cars bikespict motor-modify sexi-model laptopharga gambar-artist fast-superbike autoshowmodel harga-kamera notebook-price diamonds-collections phones-gallery camera-prices home-pic audio-gallery autocarpict living-cares homes life-style
Cool Site
this site is verry cool!
Masariq Blog
I start reading your articles
I start reading your articles and other content each and every morning. The website content hits on virtually all the important details and furthermore it is helpful. Terrific. download movies
Home Decor -improvement
Keuken renovatie De mogelijkheden voor keuken renovatie bij Visker Keukens zijn haast oneindig. Uw keuken zal als nieuw zijn en exact zoals u wilt. Een keuken renovatie van Visker Keukens is nog echt maatwerk: geen twee keukens zijn hetzelfde. Onze vakmensen maken van uw keuken weer een prachtig plaatje, u kunt weer echt genieten van uw keuken.
Especially TourGuide are one
Especially TourGuide are one of the most essential requirement which will definitely provides assistance, information and cultural, historical contemporary heritage interpretation.Well elaboration in each and every steps for better understanding. bed bugs
On of the very important part
On of the very important part in this tutorial was at this line mc.zoomTo(map.getZoomLevel() + 1), i was getting too much errors at this, iPhone is a life savior, without i couldn't come to this tutorial.
thanks
This web site is really a walk-through for all of the info you wanted about this and didn’t know who to ask. Glimpse here, and you’ll definitely discover it.
myegy
ماى ايجى
ماي ايجي
my egy
Keep sharing
This is one of the best post that I had ever read on web of this topic. You have done an excellent job here by posting such an informative post. Keep sharing buddy... Optimasi SEO
This tour guide is a method
This tour guide is a method for virtual sightseeing.I am glad to know all these new trends which are attracting users towards androids and I think its better to efficiently use all these features for your benefits.
plenty of fish
loving tour
I visited your blog for the first time and just been your fan. Thanks for Share With Irfan and so you can read my last post Mari Berkomunitas Di Faceblog on my blog.
Mari Berkomunitas Di Faceblog Mari Berkomunitas Di Faceblog Mari Berkomunitas Di Faceblog Mari Berkomunitas Di Faceblog Mari Berkomunitas Di Faceblog Mari Berkomunitas Di Faceblog
Really Really Thanks For This
Really Really Thanks For This Wonderful article. Its glad that nowadays also, there is some original content on the internet. Otherwise, everywhere you go you will find duplicate content. Thanks Again. Like to Read You article and blog.
movie download | mediafire links | all buzzy news
perfect
I now have a clear idea on what this matter is all about. Thanks for Share With Irfan and so you can read my last post daftar blog dofollow 2011 terbaru on my blog.
Android
Interesting article, please add some
free tv shows
Android
Very interesting information
free tv shows
Property Nevis Island for sale and rent
villas in nevisProperty Nevis Island for sale and rent. Villas and apartments for sale and rental. Paradise island of Nevis is one of the best kept secrets of the Caribbean.
That’s pretty good article, I
That’s pretty good article, I really like the tips you have given.Will be referring a lot of friends about this.Thanks a lot for sharing.Keep blogging.
Edinburgh BMX Shop
I use these sites, they all
I use these sites, they all work for anything. Many of the proxies posted on here have alot of popups or anoying adware and the displayed website is all messed up. This proxy shows the webpage as is, the only ads are on the main page
Dog Life Jacket
I've found the post to be
I've found the post to be very useful lesson on this mapactivity. I appreciate the excellent work in this regard. Your tourguide, a virtual sightseeing is really very helpful and informative article. thanks. business valuations
nice tips :)
nice tips ....
hopefully in the near future I can buy hp android ...
aamiin:)
regards
install ubuntu
Couldn't be written any
Couldn't be written any better. Reading this post reminds me.
Komodo Island is the New 7 Wonders of the World|Rinca The Komodo Island|Komodo New 7 Wonders|komodo island new 7 wonder
wonderful
This weblog is solely wonderful, I believed I know a lot, but I’m so improper, like the old saying the more you realize, the extra you learn the way little you know. Thanks for the info.
Aqiah di Jakarta- catering aqiqah-PercetakanPercetakan di tangerang- Aqiqah - Aqiqah Jakarta -Madu anak
spent some time browsing
spent some time browsing forums about hacking android,.. and now I know, that it won't run on mips Data Safes
Thanks for sharing
Thanks for sharing information about "TourGuide - Virtual Sightseeing" application.
GSM Kampanya | Bilişim Teknoloji | Cep Telefonu | Turkcell Kampanyaları | Avea Kampanyaları | Vodafone Kampanyaları
thanks a lot, I have not
thanks a lot, I have not quite understand about your article but from the little that I read I can understand what she meant,
Mothers Day Flowers
Sarang Semut Papua
This article is really impressive and interesting.Thanks you very much for shearing this information.
by sarang semut
Steroid-Sale.Com is a legal
Steroid-Sale.Com is a legal online Cheap Anabolic Steroids Supplier. All our products comes directly from manufacturers and best legit pharmacies. In our pharmacy you can buy steroids and not only. We colaborate with the best steroids world brands: Geneza Pharmaceuticals, Sciroxx, Iran Hormone, Gen-Shi Laboratories, Balkan Pharmaceuticals, Axiolabs and other. Steroid-Sale.Com offers exclusive high quality legal steroids.
Nice info, Thanks so much
Wow, finally i found it..
thanks so much :)
Interesting post and I really
Interesting post and I really like your take on the issue. I now have a clear idea on what this matter is all about. Thank you so much. get facebook fans
i've tried this application,
i've tried this application, and it's strongly recommended application
zippy designs
I use these sites, they all
I use these sites, they all work for anything. Many of the proxies posted on here have alot of popups or anoying adware and the displayed website is all messed up. This proxy shows the webpage as is, the only Bankruptcy San Diego
Very informative and useful
Very informative and useful article indeed. I really like the way writer has presented his views. I hope to see more great articles in future as well.mobility scooters
ooow good
nice picture...excellent
hiking
belanja
electronic
I think the concept with Java
I think the concept with Java was good, but it hasn't been followed.
The problem is that everyone creating a new platform wants to make their own API's for accessing various functionality. And this is silly.
All platforms have a screen for example. So why can't I draw a line on all those platforms using the same command? Because the creators chose not to do it like that, and thus renders Java no better than C/C++.
Property Investment
I think the concept with Java
I think the concept with Java was good, but it hasn't been followed.
The problem is that everyone creating a new platform wants to make their own API's for accessing various functionality. And this is silly.
All platforms have a screen for example. So why can't I draw a line on all those platforms using the same command? Because the creators chose not to do it like that, and thus renders Java no better than C/C++.
Property Investment
While reading your blog it
While reading your blog it seems that you research on this topic very much. I must tell you that your blog is very informative and it helps other also.
by:
belajar komputer
trik komputer
Considerably, this post is
Considerably, this post is really the sweetest on this notable topic. I harmonise with your conclusions and will thirstily look forward to your incoming updates. Saying thanks will not just be sufficient, for the phenomenal clarity in your writing. I will directly grab your rss feed to stay informed of any updates. Admirable work and much success in your business dealings! Please excuse my poor English as it is not my first tongue.
Javahostindo Web Hosting Indonesia
JJavahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
Javahostindo Web Hosting Indonesia
avahostindo Web Hosting Indonesia