mylocationoverlay help

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

mylocationoverlay help

Postby xiaodar » Mon Jul 19, 2010 9:41 am

hi, i'm developing an app that allows me to mark location on the map and show my current location.
i've error with the mylocationoverlay. hence i created a new app to test it out.
i was able to display the map
howvere when i call the
initMyLocation();
an error occur requireing me to force close my app.
i'm folllowing this url for the location overlay
http://blogs.itemis.de/frey/2009/04/04/ ... id-part-1/
can any1 help me please, thanks in advance
my codes:

GPSTEST.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.gpstest;
  2.  
  3. import android.os.Bundle;
  4. import android.view.View;
  5. import android.widget.LinearLayout;
  6.  
  7. import com.google.android.maps.MapActivity;
  8. import com.google.android.maps.MapView;
  9. import com.google.android.maps.MyLocationOverlay;
  10.  
  11. /**
  12.  * This application demonstrates the use of the google maps view in combination
  13.  * with a MyLocationOverlay.
  14.  *
  15.  * @author frey
  16.  */
  17. public class GPSTEST extends MapActivity {
  18.  
  19.         private MapView myMap;
  20.         private MyLocationOverlay myLocOverlay;
  21.  
  22.         /** Called when the activity is first created. */
  23.         @Override
  24.         public void onCreate(Bundle savedInstanceState) {
  25.                 super.onCreate(savedInstanceState);
  26.                 setContentView(R.layout.main);
  27.  
  28.                 initMap();
  29.                 initMyLocation();
  30.         }
  31.  
  32.         /**
  33.          * Initialise the map and adds the zoomcontrols to the LinearLayout.
  34.          */
  35.         private void initMap() {
  36.                 myMap = (MapView) findViewById(R.id.mapview);
  37.  
  38.                 View zoomView = myMap.getZoomControls();
  39.                 LinearLayout myzoom = (LinearLayout) findViewById(R.id.myzoom);
  40.                 myzoom.addView(zoomView);
  41.                 myMap.displayZoomControls(true);
  42.  
  43.         }
  44.  
  45.         /**
  46.          * Initialises the MyLocationOverlay and adds it to the overlays of the map
  47.          */
  48.         private void initMyLocation() {
  49.                 myLocOverlay = new MyLocationOverlay(this, myMap);
  50.                 myLocOverlay.enableMyLocation();
  51.                 myMap.getOverlays().add(myLocOverlay);
  52.  
  53.         }
  54.  
  55.         @Override
  56.         protected boolean isRouteDisplayed() {
  57.                 return false;
  58.         }
  59. }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4



android manifest

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.       package="com.gpstest"
  4.       android:versionCode="1"
  5.       android:versionName="1.0">
  6.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  7.                 <uses-library android:name="com.google.android.maps" />    
  8.         <activity android:name=".GPSTEST"
  9.                   android:label="@string/app_name">
  10.             <intent-filter>
  11.                 <action android:name="android.intent.action.MAIN" />
  12.                 <category android:name="android.intent.category.LAUNCHER" />
  13.             </intent-filter>
  14.         </activity>
  15.  
  16.     </application>
  17. <uses-permission android:name="android.permission.INTERNET" />
  18. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  19. </manifest>
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


main xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <RelativeLayout
  2.  xmlns:android="http://schemas.android.com/apk/res/android"
  3.  android:orientation="vertical"
  4.  android:layout_width="fill_parent"
  5.  android:layout_height="fill_parent">
  6.   <com.google.android.maps.MapView
  7.        android:id="@+id/mapview"
  8.        android:layout_width="fill_parent"
  9.        android:layout_height="fill_parent"
  10.        android:clickable="true"
  11.        android:apiKey="0j5tYJai2sXmANTGvYmeaIQ9uGVeZXZlCTcScYQ"
  12.    />
  13.   <LinearLayout
  14.    android:layout_width="wrap_content"
  15.    android:layout_height="wrap_content"
  16.    android:id="@+id/myzoom"
  17.    android:layout_alignParentBottom="true"
  18.    android:layout_centerHorizontal="true"
  19.  />
  20. </RelativeLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
xiaodar
Junior Developer
Junior Developer
 
Posts: 16
Joined: Wed Mar 24, 2010 9:51 am

Top

Re: mylocationoverlay help

Postby Kirisawa » Fri Aug 20, 2010 3:39 pm

Can you provide some more info from the LogCat?
Kirisawa
Freshman
Freshman
 
Posts: 5
Joined: Fri Aug 20, 2010 3:06 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests