карта не загружается - PullRequest
       5

карта не загружается

0 голосов
/ 19 января 2012

У меня есть простое приложение, которое должно отображать местоположение устройства на карте. приложение вроде работает отдельно от карты не загружается, а вместо этого серая сетка. Я сделал некоторые записи и посмотрел на трассировку стека. упоминается, что MapActivity не удалось получить клиента фабрики соединений. Я просмотрел несколько тем по этому вопросу, но не могу найти ответ.

когда приложение запущено, оно просто бесконечно переключается между onDraw и onLocationChanged. я создал MapView apiKey, также правильные разрешения в манифесте. Любые идеи, что я мог сделать? спасибо.

[править] Я тоже гулял снаружи, потому что в здании нет gps:)

[edit2] Я также пытался восстановить другой отпечаток md5 для создания другого apikey, но keytool генерирует тот же отпечаток md5. это псевдоним Matt уже существует.

[edit3] Я также сгенерировал другой отпечаток MD5, используя другой псевдоним в keytool. Это сделало другой API KEY, к сожалению, он все еще не работает

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical" android:layout_width="match_parent" 
                android:layout_height="wrap_content" android:gravity="fill">
   <com.google.android.maps.MapView
        android:id="@+id/myGMap"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="0??????syQI//C13Y-pRUNaA0a_??????pr86jE2w"
     />

   <EditText android:id="@+id/edittext1" 
             android:inputType="text"
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content" 
             />

   <Button android:layout_height="wrap_content" 
          android:layout_width="wrap_content" 
          android:text="CLOSE"
          android:layout_alignParentRight="true"  
          android:id="@+id/close" ></Button> 

</RelativeLayout>

.

<?xml version="1.0" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.tecmark"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="7" />
     <uses-permission android:name="android.permission.INTERNET"></uses-permission>

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <activity
            android:name=".WcFinderActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <uses-library android:name="com.google.android.maps" />
    </application>



</manifest>

.

import java.util.List;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;


import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ZoomControls;

public class WcFinderActivity extends MapActivity implements LocationListener {
    /** Called when the activity is first created. */



    private MapView         gMapView        = null;
    private MapController   mc              = null;
    private Drawable        defaultMarker   = null;
    private GeoPoint        p               = null;
    private double          latitude        = 18.9599990845;
    private double          longitude = 72.819999694;
    private Context         mContext = this;

    private static final String TAG = "WcFinderActivity";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Log.e(TAG, "**********inside oncreate");

        EditText editText = (EditText)findViewById(R.id.edittext1);


        // Creating and initializing Map
        gMapView = (MapView) findViewById(R.id.myGMap);
        p = new GeoPoint((int) (latitude * 1000000), (int) (longitude * 1000000));
        gMapView.setSatellite(true);
        mc = gMapView.getController();
        mc.setCenter(p);
        mc.setZoom(14);

        // Add a location mark
        MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
        List<Overlay> list = gMapView.getOverlays();
        list.add(myLocationOverlay);

        // Adding zoom controls to Map
        ZoomControls zoomControls = (ZoomControls) gMapView.getZoomControls();
        zoomControls.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));

        gMapView.addView(zoomControls);
        gMapView.displayZoomControls(true);

        // Getting locationManager and reflecting changes over map if distance travel by
        // user is greater than 500m from current location.
        Log.e(TAG, "**********about to call getSystemService");
        LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        Log.e(TAG, "**********about to call requestLocationUpdates");
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
        lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);



        Button close = (Button)findViewById(R.id.close);
        close.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                Log.e(TAG,"clicked close");

            finish();

            }});

    }

    /* This method is called when use position will get changed */
    public void onLocationChanged(Location location) {
        if (location != null) {
            Log.e(TAG, "**********inside onLocationChanged");
            double lat = location.getLatitude();
            double lng = location.getLongitude();

            p = new GeoPoint((int) lat * 1000000, (int) lng * 1000000);
            mc.animateTo(p);
        }
    }

    public void onProviderDisabled(String provider) {
        // required for interface, not used

        Log.e(TAG, "**********inside onProviderDisabled");
    }

    public void onProviderEnabled(String provider) {
        // required for interface, not used
        Log.e(TAG, "**********inside onProviderEnabled");
    }

    public void onStatusChanged(String provider, int status, Bundle extras) {
        // required for interface, not used
        Log.e(TAG, "**********inside onStatusChanged");
    }

    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        Log.e(TAG, "**********inside isRouteDisplayed");
        return false;
    }

    /* User can zoom in/out using keys provided on keypad */
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_I) {
            gMapView.getController().setZoom(gMapView.getZoomLevel() + 1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_O) {
            gMapView.getController().setZoom(gMapView.getZoomLevel() - 1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_S) {
            gMapView.setSatellite(true);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_T) {
            gMapView.setTraffic(true);
            return true;
        }
        return false;
    }

    /* Class overload draw method which actually plot a marker,text etc. on Map */
    protected class MyLocationOverlay extends com.google.android.maps.Overlay {

        @Override
        public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {

            super.draw(canvas, mapView, shadow);
            Paint paint = new Paint();
            Log.e(TAG, "**********inside onDraw");
            // Converts lat/lng-Point to OUR coordinates on the screen.
            Point myScreenCoords = new Point();
            mapView.getProjection().toPixels(p, myScreenCoords);

            paint.setStrokeWidth(1);
            paint.setARGB(255, 255, 255, 255);
            paint.setStyle(Paint.Style.STROKE);
            paint.setColor(Color.RED);


            canvas.drawCircle(myScreenCoords.x, myScreenCoords.y, 20, paint);
            canvas.drawText("I am here...", myScreenCoords.x, myScreenCoords.y, paint);
            return true;
        }
    }
}

.

01-19 16:13:59.698: D/ddm-heap(2294): Got feature list request
01-19 16:14:00.893: E/WcFinderActivity(2294): **********inside oncreate
01-19 16:14:01.073: E/WcFinderActivity(2294): **********about to call getSystemService
01-19 16:14:01.083: D/LocationManager(2294): Constructor: service = android.location.ILocationManager$Stub$Proxy@43cf74d8
01-19 16:14:01.083: E/WcFinderActivity(2294): **********about to call requestLocationUpdates
01-19 16:14:01.398: I/MapActivity(2294): Handling network change notification:CONNECTED
01-19 16:14:01.398: E/MapActivity(2294): Couldn't get connection factory client
01-19 16:14:01.438: E/WcFinderActivity(2294): **********inside isRouteDisplayed
01-19 16:14:01.613: D/dalvikvm(2294): GC freed 3423 objects / 218896 bytes in 81ms
01-19 16:14:02.003: D/dalvikvm(2294): GC freed 6408 objects / 380712 bytes in 87ms
01-19 16:14:02.283: E/WcFinderActivity(2294): **********inside onDraw
01-19 16:14:02.378: D/dalvikvm(2294): GC freed 10136 objects / 744376 bytes in 77ms
01-19 16:14:02.383: E/WcFinderActivity(2294): **********inside onDraw
01-19 16:14:02.423: E/WcFinderActivity(2294): **********inside onLocationChanged
01-19 16:14:02.448: E/WcFinderActivity(2294): **********inside onLocationChanged
01-19 16:14:02.493: E/WcFinderActivity(2294): **********inside isRouteDisplayed
01-19 16:14:02.523: E/WcFinderActivity(2294): **********inside onDraw
01-19 16:14:02.528: E/WcFinderActivity(2294): **********inside onDraw
01-19 16:14:02.578: E/WcFinderActivity(2294): **********inside isRouteDisplayed
01-19 16:14:02.603: E/WcFinderActivity(2294): **********inside onDraw

Ответы [ 2 ]

0 голосов
/ 21 января 2012

это то, что я сделал.

keytool -list -alias androiddebugkey -keystore "c:\Users\matt\debug.keystore" -storepass android -keypass android
0 голосов
/ 19 января 2012

вы получили ключ API для своего сертификата отладки?Если нет, то это ваша проблема.

попробуйте прочитать эту статью, чтобы узнать, как это сделать

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...