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
-
@phmagdalo (Magdalo)The "Pets" collection in Big Business has been completed! 51 http://t.co/5VuNBXlY #android #gameinsight #androidgames
12 min 47 sec ago -
@cherry3302 (cherry3302)Start playing Paradise Island on Android http://t.co/QdZhS9HC #Android #Androidgames #Gameinsight http://t.co/NMnfmMTg
12 min 48 sec ago -
@heavensent2471 (heaven sent)Start playing Paradise Island on Android http://t.co/smnULBNy #Android #Androidgames #Gameinsight http://t.co/QYDRex8q
12 min 50 sec ago -
@Nadrolf (Flordan delos Reyes)Start playing Paradise Island on Android http://t.co/xn6hZ7Ur #Android #Androidgames #Gameinsight http://t.co/a6G02cnX
12 min 54 sec ago -
@aagahi (Alexis Agahi)RT @v3rtti: Blogged: Developing a Realtime Android Game - Lessons Learned - Part I : http://t.co/BEeZhQjw #android #scala #gamedev
13 min ago
Poll
Useful resources
Android Development Projects
- Private project for Petterpp1 [WRD] by geomaster909
- Modifications on an Android Game by tymex
- app dev for techcity by dany2g
- Android App by dvlinh
- Iphone app by nabzyd
- Betfair Mobile App by Daaniel
- Need App Developer/Designer for iPhone, iPad by lplco
- Android Maps - Saving GeoLocations to MySql database. by adelshehri
- Prototype Android Apps display Information from database by getitonline
- Metal Weigh Calculator by mpmakwana



Comments
Great ArticlE >> ThX AloT
Great ArticlE >> ThX AloT ..
I ReallY EnjoyeD ReadinG it
It is very useful .. and u have great style
I hope u can visit my site below
And .. I,m Waiting for more
شات مصرى ,
شات مصرى ,
شات مصرى ,
شات مصرية ,
شات مصريه ,
دردشة مصرية ,
دردشة بنت مصرية ,
شات بنت مصرية ,
شات بنت مصر ,
دردشة بنت مصر ,
شات ,
دردشه مصريه ,
شات بنات مصر ,
دردشة بنات مصر ,
شات مصرى بنات ,
شات مصر ,
دردشة ,
شات اسكندرية ,
شات القاهرة ,
شات المنصورة ,
شات طنطا ,
شات السويس ,
شات الشرقية ,
شات المنوفية ,
شات الفيوم ,
شات بنى سويف ,
شات سوهاج ,
شات الصعيد ,
شات الزقازيق ,
شات جامعة القاهرة ,
شات جامعة اسكندرية ,
شات بنت السعودية ,
شات بنت البحرين ,
شات بنت الكويت ,
شات بنت فلسطين ,
شات بنت المغرب ,
شات بنت الامارات ,
شات بنت اليمن ,
شات بنت العراق ,
شات مصراوى ,
شات بنات ,
روتانا سينما ,
روتانا سينما مشاهدة مباشرة ,
روتانا سينما بث مباشر ,
روتانا سينما اونلاين ,
I hope u can find something useful About it .. Enjoy
Thanks .. lol i had to read it twice
Great ArticlE >> ThX AloT
Great ArticlE >> ThX AloT ..
I ReallY EnjoyeD ReadinG it
It is very useful .. and u have great style
I hope u can visit my site below
And .. I,m Waiting for more
شات مصرى ,
شات مصرى ,
شات مصرى ,
شات مصرية ,
شات مصريه ,
دردشة مصرية ,
دردشة بنت مصرية ,
شات بنت مصرية ,
شات بنت مصر ,
دردشة بنت مصر ,
شات ,
دردشه مصريه ,
شات بنات مصر ,
دردشة بنات مصر ,
شات مصرى بنات ,
شات مصر ,
دردشة ,
شات اسكندرية ,
شات القاهرة ,
شات المنصورة ,
شات طنطا ,
شات السويس ,
شات الشرقية ,
شات المنوفية ,
شات الفيوم ,
شات بنى سويف ,
شات سوهاج ,
شات الصعيد ,
شات الزقازيق ,
شات جامعة القاهرة ,
شات جامعة اسكندرية ,
شات بنت السعودية ,
شات بنت البحرين ,
شات بنت الكويت ,
شات بنت فلسطين ,
شات بنت المغرب ,
شات بنت الامارات ,
شات بنت اليمن ,
شات بنت العراق ,
شات مصراوى ,
شات بنات ,
روتانا سينما ,
روتانا سينما مشاهدة مباشرة ,
روتانا سينما بث مباشر ,
روتانا سينما اونلاين ,
I hope u can find something useful About it .. Enjoy
Thanks .. lol i had to read it twice
Great ArticlE >> ThX AloT
Great ArticlE >> ThX AloT ..
I ReallY EnjoyeD ReadinG it
It is very useful .. and u have great style
I hope u can visit my site below
And .. I,m Waiting for more
شات مصرى ,
شات مصرى ,
شات مصرى ,
شات مصرية ,
شات مصريه ,
دردشة مصرية ,
دردشة بنت مصرية ,
شات بنت مصرية ,
شات بنت مصر ,
دردشة بنت مصر ,
شات ,
دردشه مصريه ,
شات بنات مصر ,
دردشة بنات مصر ,
شات مصرى بنات ,
شات مصر ,
دردشة ,
شات اسكندرية ,
شات القاهرة ,
شات المنصورة ,
شات طنطا ,
شات السويس ,
شات الشرقية ,
شات المنوفية ,
شات الفيوم ,
شات بنى سويف ,
شات سوهاج ,
شات الصعيد ,
شات الزقازيق ,
شات جامعة القاهرة ,
شات جامعة اسكندرية ,
شات بنت السعودية ,
شات بنت البحرين ,
شات بنت الكويت ,
شات بنت فلسطين ,
شات بنت المغرب ,
شات بنت الامارات ,
شات بنت اليمن ,
شات بنت العراق ,
شات مصراوى ,
شات بنات ,
روتانا سينما ,
روتانا سينما مشاهدة مباشرة ,
روتانا سينما بث مباشر ,
روتانا سينما اونلاين ,
I hope u can find something useful About it .. Enjoy
Thanks .. lol i had to read it twice
Great ArticlE >> ThX AloT
Great ArticlE >> ThX AloT ..
I ReallY EnjoyeD ReadinG it
It is very useful .. and u have great style
I hope u can visit my site below
And .. I,m Waiting for more
شات مصرى ,
شات مصرى ,
شات مصرى ,
شات مصرية ,
شات مصريه ,
دردشة مصرية ,
دردشة بنت مصرية ,
شات بنت مصرية ,
شات بنت مصر ,
دردشة بنت مصر ,
شات ,
دردشه مصريه ,
شات بنات مصر ,
دردشة بنات مصر ,
شات مصرى بنات ,
شات مصر ,
دردشة ,
شات اسكندرية ,
شات القاهرة ,
شات المنصورة ,
شات طنطا ,
شات السويس ,
شات الشرقية ,
شات المنوفية ,
شات الفيوم ,
شات بنى سويف ,
شات سوهاج ,
شات الصعيد ,
شات الزقازيق ,
شات جامعة القاهرة ,
شات جامعة اسكندرية ,
شات بنت السعودية ,
شات بنت البحرين ,
شات بنت الكويت ,
شات بنت فلسطين ,
شات بنت المغرب ,
شات بنت الامارات ,
شات بنت اليمن ,
شات بنت العراق ,
شات مصراوى ,
شات بنات ,
روتانا سينما ,
روتانا سينما مشاهدة مباشرة ,
روتانا سينما بث مباشر ,
روتانا سينما اونلاين ,
I hope u can find something useful About it .. Enjoy
Thanks .. lol i had to read it twice
Best fuction
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.
a b c d e f g h i j
============================== ===========================
ipad bag blog
Sutudeg Community
Education News
============================== ===========================
a visit b visit c visit d visit e visit f visit g visit h visit i visit j visit k visit l visit m visit n visit o visit p visit q visit r visit s visit t visit u visit v visit w visit x visit y visit z visit aa visit ab visit ac visit ad visit ae visit af visit ag visit ah visit ai visit aj visit ak visit al visit am visit an visit ao visit ap visit aq visit ar visit as visit at visit au visit av visit aw visit ax visit ay visit az visit ba visit bb visit bc visit bd visit be visit bf visit bg visit bh visit bi visit bk visit bl visit bm visit bn visit bo visit bp visit bq visit br visit bs visit bt visit bu visit bv visit bw visit bx visit by visit bz visit ca visit cb visit cc visit cd visit ce visit cf visit cg visit ch ci cj ck cl ccl cm cn co cp cq cr cs ct cu cv
============================== ===========================
دردشة سورية دردشة
دردشة سورية
دردشة لبنانية
دردشة عراقية
شات سوري
شات لبناني
دردشة سوريا
دردشة لبنان
شات سوريا
شات لبنان
دردشة السويدي
منتديات السويدي
اغاني عراقية
صور فنانين
الرياضة العراقية
شعراء العراق
نغمات عراقية
اغاني عربية
اغاني كردية
دردشة عراقية
دردشة بنات العراق
دردشة صبايا بغداد
دردشة البصره
دردشة بغداد
دردشة بغدادية
دردشة صبايا بغداد
دردشة شباب العراق
دردشة بنات العراق
دردشة الكرادة
دردشة دمشق
دردشة بيروت
دردشة حلب
دردشة حلب
دردشة عراقية
دردشة العراق
شات عراقي
جات عراقي
دردشه عراقيه
دردشة صبايا لبنان
دردشة بنات لبنان
شات صوتي | دردشة صوتية | كلام
شات صوتي
| دردشة صوتية
|
كلام
| شات كلام
|
دردشة كلام
| دردشة صوتية
|
شات صوتي
| شات
|
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