Draw Bitmap on current GPS-Location

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Draw Bitmap on current GPS-Location

Postby faedas » Fri Mar 26, 2010 6:04 pm

Hi. I'm facing a little problem right now.

In my App i have to draw a Bitmap at my current location in order to draw a route to an other location.

What do i have to do to get the GeoPoint of my current location.
I dont have to update it constantly, just have to draw it once.
faedas
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Dec 03, 2009 7:09 pm
Location: Germany, Aachen

Top

Re: Draw Bitmap on current GPS-Location

Postby hwrdprkns » Fri Mar 26, 2010 6:27 pm

faedas wrote:Hi. I'm facing a little problem right now.

In my App i have to draw a Bitmap at my current location in order to draw a route to an other location.

What do i have to do to get the GeoPoint of my current location.
I dont have to update it constantly, just have to draw it once.


To get the GeoPoint of your current location you'd need to do something like

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Location loc;
  3.  
  4. locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  5.  
  6. GeoPoint point = new GeoPoint(( (int) loc.getLatitude())*1e6, ((int) loc.getLongitude())*1e6);
  7.  
  8.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


that should give you a GeoPoint that has your current location built in. Oh ya, and
The more you learn, the less you know.
hwrdprkns
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Nov 25, 2009 8:14 am

Re: Draw Bitmap on current GPS-Location

Postby faedas » Fri Mar 26, 2010 6:37 pm

hwrdprkns wrote:
To get the GeoPoint of your current location you'd need to do something like

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Location loc;
  3.  
  4. locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  5.  
  6. GeoPoint point = new GeoPoint(( (int) loc.getLatitude())*1e6, ((int) loc.getLongitude())*1e6);
  7.  
  8.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


that should give you a GeoPoint that has your current location built in


Thanks.
I tried that before, but i get an error.
How do i have to initialize the loc-var to get the current cords :) ?
faedas
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Dec 03, 2009 7:09 pm
Location: Germany, Aachen

Re: Draw Bitmap on current GPS-Location

Postby hwrdprkns » Fri Mar 26, 2010 6:45 pm

faedas wrote:
hwrdprkns wrote:
To get the GeoPoint of your current location you'd need to do something like

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Location loc;
  3.  
  4. locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  5.  
  6. GeoPoint point = new GeoPoint(( (int) loc.getLatitude())*1e6, ((int) loc.getLongitude())*1e6);
  7.  
  8.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


that should give you a GeoPoint that has your current location built in


Thanks.
I tried that before, but i get an error.
How do i have to initialize the loc-var to get the current cords :) ?


What error does logcat give? NullPointerException?
The more you learn, the less you know.
hwrdprkns
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Nov 25, 2009 8:14 am

Re: Draw Bitmap on current GPS-Location

Postby faedas » Fri Mar 26, 2010 6:54 pm

hwrdprkns wrote:
What error does logcat give? NullPointerException?


yes, it was a NullPointerException. Any Idea?
faedas
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Dec 03, 2009 7:09 pm
Location: Germany, Aachen

Re: Draw Bitmap on current GPS-Location

Postby hwrdprkns » Fri Mar 26, 2010 7:00 pm

faedas wrote:
hwrdprkns wrote:
What error does logcat give? NullPointerException?


yes, it was a NullPointerException. Any Idea?



Can you pastebin or post you code?

As of now, i'd say add a location listener. That way it will update to wherever you are at any point in time.
The more you learn, the less you know.
hwrdprkns
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Nov 25, 2009 8:14 am

Top

Re: Draw Bitmap on current GPS-Location

Postby faedas » Fri Mar 26, 2010 7:13 pm

hwrdprkns wrote:Can you pastebin or post you code?

As of now, i'd say add a location listener. That way it will update to wherever you are at any point in time.


I just found the sollution:

.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Location loc = locationManager.getLastKnownLocation(locationManager.getBestProvider(new Criteria (), true));
  2. Geopoint gps = new .........
  3.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


but you have to update the Location before that I think. :)
faedas
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Dec 03, 2009 7:09 pm
Location: Germany, Aachen

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 1 guest