0

please help. i have tried a code which should give my current location with marker on google map. but it is not working. i have give my location via DDMS and TELNET but still in dark. what should i do?? the code is:

package com.chupamobile.android.googlemaps;

import android.location.Location;

public class GoogleMapsActivity extends MapActivity{
    private MapView myMap;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        myMap = (MapView) findViewById(R.id.mymap);
        initMap();
        initMyLocation();
    }

    /**
     * Initialise the map and adds the zoomcontrols to the LinearLayout.
     */
    private void initMap() {
        //myMap = (MapView) findViewById(R.id.mymap);

        View zoomView = myMap.getZoomControls();
        //MapController mc = myMap.getController();
        //mc.setZoom(16);
        LinearLayout myzoom = (LinearLayout) findViewById(R.id.myzoom);
        myzoom.addView(zoomView);
        myMap.displayZoomControls(true);

    }

    /**
     * Initialises the MyLocationOverlay and adds it to the overlays of the map
     */
    private void initMyLocation() {

        MyLocationOverlay myLocOverlay = new MyLocationOverlay(this, myMap);
        myLocOverlay.enableMyLocation();
        myLocOverlay.enableCompass();
        myMap.getOverlays().add(myLocOverlay);
        Toast.makeText(getApplicationContext(), "I am In"+myLocOverlay, Toast.LENGTH_LONG).show();


    }

    /*public void onLocationChanged(Location location){
        if(location!=null){
            GeoPoint point = new GeoPoint((int)(location.getLatitude()*1E6),(int)(location.getLongitude()*1E6));
            MapController mc = myMap.getController();
            mc.animateTo(point);
            mc.setZoom(16);
        }

    }
*/ 

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}
Shoshi
  • 2,254
  • 1
  • 29
  • 43

3 Answers3

1

There is a 4 part Youtube Tutorial by Thenewboston, that goes through practically every part of the api, pining location etc. each video is about 5min each, its pretty easy to follow, I think he talks about pinning location in the second video. Also I found that the accepted answer to this question may help guide you in the right direction as well.

Community
  • 1
  • 1
The Tokenizer
  • 1,564
  • 3
  • 29
  • 46
0

Have you put this permissions <uses-library android:name="com.google.android.maps"/> and <uses-permission android:name="android.permission.INTERNET"/> in your manifest? And have selected the Google APIs in your project->properties-> Android? Also have you got your MD5 certificate? For a complete official tutorial look here https://developers.google.com/maps/documentation/android/hello-mapview

Dinesh Venkata
  • 1,087
  • 1
  • 9
  • 22
  • yes i have. i have done all the thing u have said. the app shows the google map but when i give the lan and lat via DDMS or TELNET, the app does not respond. @Dinesh Venkata – Shoshi Oct 05 '12 at 19:20
0

Downad full working demo :

http://www.filedropper.com/androidopenstreetmapview120516a

If map is not display in emulator or mobile device then change Map API key .

Nirav Ranpara
  • 13,753
  • 3
  • 39
  • 54