The Friend Finder - MapActivity using GPS - Part: II / II

Tutorials that use the MapActivity. Many using GPS functionality.

Postby navajo » Tue Jan 08, 2008 9:15 pm

When starting your application the map is always centered to Tulsa (USA). Where are the coordinates of this location defined? I mean: in which file in the android system can I find these coordinates?
In a world without walls and fences... who needs Windows and Gates?
navajo
Junior Developer
Junior Developer
 
Posts: 15
Joined: Fri Dec 21, 2007 5:55 pm
Location: Germany

Top

Postby plusminus » Tue Jan 08, 2008 9:50 pm

Hello navajo,

you are talking of the "Me"-Location :?:

But you can create :src: your own Mock Location Provider (as real GPS-devices are not supported in the emulator).

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby navajo » Tue Jan 08, 2008 10:11 pm

Thanks for your quick reply!

No, I'm not talking about ME-Location. I am talking about the coordinates when the map is first centered, and on my map this is Tulsa (USA). U use zoom level 3 in your code, and if I zoom in, then I get to Tulsa and not next to "Bayshore Fwy". I'm wondering where these default coordinates come from.

Defining my own mock-gps-provider is known to me...
Hope my question is more precise now :)
In a world without walls and fences... who needs Windows and Gates?
navajo
Junior Developer
Junior Developer
 
Posts: 15
Joined: Fri Dec 21, 2007 5:55 pm
Location: Germany

Postby plusminus » Tue Jan 08, 2008 11:47 pm

Hello navajo,

hehe, didn't even recognize this, but when you open the System-Map-Activity the map is centered there to. (Thought that it the initial sdk-release it was pointing to the middle of the world map (atlantic ocean).

So perhaps on of the Android-Map-Activity-Coders lost a bet or sth. :lol: .

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby glider » Wed Jan 09, 2008 10:24 am

Thanks - the below worked!

sth. like this should work:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.        // Animate to the center
  2.  
  3.           myMapView.getController().animateTo(new Point(lat.intValue(),lng.intValue()));
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Another question - is it possible to preload/cache the maps ?
(assuming you have/can simulate the gps track ?)
I.e if you expect no network coverage but you still like a moving map.
glider
Freshman
Freshman
 
Posts: 4
Joined: Thu Jan 03, 2008 2:37 am

Postby plusminus » Wed Jan 09, 2008 5:34 pm

Hello glider,

haven't seen such a functionality yet, would probably be done centrally by the underlying System-Map-"""Provider""".
Caching data for specified customizable locations would be an idea, as it would just take a few megabytes for a medium town (but just on one Zoom-Level !)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby KC » Thu Jan 10, 2008 10:02 am

Hello,

(my first post)
I used the next code to always center the "ME" location on the screen (in UpdateView):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.           Point point = new Point(lat.intValue(), lng.intValue());
  2.  
  3.           myMapController.centerMapTo(point, false);
  4.  
  5.           this.myMapView.invalidate();
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


regards, KC
KC
Freshman
Freshman
 
Posts: 2
Joined: Mon Jan 07, 2008 11:52 am
Location: Netherlands

Postby glider » Thu Jan 10, 2008 12:22 pm

Maybe if android use a http proxy ? Would that work in this case ?

Thanks for all your help!!!

plusminus wrote:Hello glider,

haven't seen such a functionality yet, would probably be done centrally by the underlying System-Map-"""Provider""".
Caching data for specified customizable locations would be an idea, as it would just take a few megabytes for a medium town (but just on one Zoom-Level !)

Regards,
plusminus
glider
Freshman
Freshman
 
Posts: 4
Joined: Thu Jan 03, 2008 2:37 am

Postby plusminus » Thu Jan 10, 2008 12:39 pm

glider wrote:Maybe if android use a http proxy ? Would that work in this case ?


You would also have to connect to that Proxy and download cached data from it so, there will be no real advantage from such a possibility.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby glider » Thu Jan 10, 2008 12:54 pm

Well, you could always run a proxy ON the handheld itself to cache the data ?
(are there any lightweight java proxies around ?)

plusminus wrote:
glider wrote:Maybe if android use a http proxy ? Would that work in this case ?


You would also have to connect to that Proxy and download cached data from it so, there will be no real advantage from such a possibility.

Regards,
plusminus
glider
Freshman
Freshman
 
Posts: 4
Joined: Thu Jan 03, 2008 2:37 am

activity vs subactivity

Postby crayder » Mon Feb 04, 2008 1:02 am

Hi! I have a question according the activity running. If I am not mistaking all the activities can be run as subactivities and simply activities. I can't understand in what cases we need to use these two different methods... Could you please point me some materials where this topic is described?
crayder
Freshman
Freshman
 
Posts: 9
Joined: Mon Feb 04, 2008 12:35 am

Postby plusminus » Mon Feb 04, 2008 1:54 am

Hello crayder,

you can put a RequestCode to a startSubActivity(...); which you cannot put to startActivity(...);. SubActivities are very useful if you want to return values from them (i.e. an InputBox). To do that you'll overwrite onActivityResult(...) where is a parameter "requestCode" which is used to determine which SubActivity actually is returning.(The requestCode is the same as you called startSubActivity(...); with).

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby crayder » Mon Feb 04, 2008 11:06 pm

Hm.. Now am understanding... May be if we present application (activities) like a tree then it'll be logically to start activities that are the leaves as subactivities.. May be ))) Nevertheless thank you for the help ;-)
crayder
Freshman
Freshman
 
Posts: 9
Joined: Mon Feb 04, 2008 12:35 am

Postby plusminus » Mon Feb 04, 2008 11:36 pm

Hello crayder,

yes a tree is what it allover looks like, (ok we could link branches of the tree). But we only can go linear, because only one Activity is on the top every time :!: (Remember Activity-Stack :!:)

So we have something like a chain of dialogs, with some A/B-Decisions (tree style) the what results in a path within the tree.

This works really fine, I'm currently doing it with my [http://www.anddev.org/viewtopic.php?t=740]AndNav[/url]-Application. Everything starts at the tree-root, the menu. To proceed to the Country,(ZipCode or CityName) ,Streetname-Activities, I call a chain of SubActivities after every part of the chain. Doing that it is very easy to go just one step back or, to go back to the Menu-Activity, by chaining the Activities like this:
ActivityC.finish() :arrow: ActivityB.onActivityResult() :arrow: ActivityB.finish() :arrow: ActivityA.onActivityResult() :arrow: ActivityA.finish() :arrow: MenuActivity :)

I hope I didn't confuse you ;)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby crayder » Tue Feb 05, 2008 10:22 pm

Wau )))
May be you are cheating? I think you are not a student - you are a teacher! ))))))
Thank you for very good explanation!
crayder
Freshman
Freshman
 
Posts: 9
Joined: Mon Feb 04, 2008 12:35 am

Top
PreviousNext

Return to Map Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests