Problem with Kml File

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

Problem with Kml File

Postby mana » Mon Jul 07, 2008 4:06 pm

Hi,
I've a problem with a kml file. So I pushed the kml file (kml.kml) and my properties file to my emulator misc/location/mygps

the I write a app with this code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.   MapController mc = mymapview.getController();
  2.  
  3.         LocationManager myLocationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
  4.  
  5.         // Get the first Providers available
  6.  
  7.         List<LocationProvider> providers = myLocationManager.getProviders();
  8.  
  9.         LocationProvider provider = providers.get(1);
  10.  
  11.         //Returns a new location fix from the given provider:
  12.  
  13.         Location curLoc = myLocationManager.getCurrentLocation("mygps");
  14.  
  15.         Point curLocAsPoint = new Point((int)(curLoc.getLatitude()* 1E6), (int)(curLoc.getLongitude()*1E6));
  16.  
  17.         mc.animateTo(curLocAsPoint);
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


My map shows a point near Afrika but it should be a location in Europe ?! I set these permissions in the manifest.xml as well:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. <uses-permission android:name="android.permission.ACCESS_LOCATION">
  2.  
  3. </uses-permission><uses-permission android:name="android.permission.ACCESS_GPS">
  4.  
  5. </uses-permission>
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I hope someone can help me. Do I forget to push some files to emulator perhaps ?
Thanks in advance !
mana
Freshman
Freshman
 
Posts: 6
Joined: Sat May 10, 2008 9:56 pm

Top

Postby plusminus » Tue Jul 08, 2008 2:19 pm

Hello mana,

usually the first call to [font=Courier New]getCurrentLocation()[/font] returns invalid values (Latitude=0 & Longitude=0).
Try calling it at least twice, in the beginning.

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 mana » Wed Jul 09, 2008 3:27 pm

Thank you +-,
the problem was that the kml file had the name kml.kml on the emulator. Then I remove the *.kml extension and now it works fine and I can see my location.
Thanks
mana
mana
Freshman
Freshman
 
Posts: 6
Joined: Sat May 10, 2008 9:56 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests