Have you gotten a Google Maps API Key? Your maps will not show until
you obtain one of these from Google. Here is the link in case you have
not. http://code.google.com/apis/maps/ you can obtain a debug one to
get you started. Once you have it, you will need to put the key in
your xml file for the mapview.

android:apiKey="API Key Goes Here"
android:clickable="true"

the clickable option allows your users to scroll around the map.

Dan

On Feb 11, 6:45 pm, Zi Yong Chua <[email protected]> wrote:
> I am working on this code, it returns no error but it doesnt display
> maps on the emulator... it doesnt seem to be able to find the mapview
>
>         @Override
>         public void onCreate(Bundle savedInstanceState) {
>                 super.onCreate(savedInstanceState);
>                 setContentView(R.layout.main);
>
>                 myMap = (MapView) findViewById(R.id.simpleGM_map); // Get map 
> from
> XML
>                 btnSearch = (Button) findViewById(R.id.simpleGM_btn_search); 
> // Get
> button from xml
>                 adress = (EditText) findViewById(R.id.simpleGM_adress); // Get
> address from XML
>
>                 gc = new Geocoder(this); // create new geocoder instance
>
>                 btnSearch.setOnClickListener(new OnClickListener() {
>                         public void onClick(View v) {
>                                 String addressInput = 
> adress.getText().toString(); // Get input
> text
>
>                                 try {
>
>                                         List<Address> foundAdresses = 
> gc.getFromLocationName(
>                                                         addressInput, 5); // 
> Search addresses
>
>                                         if (foundAdresses.size() == 0) { // 
> if no address found,
>                                                 // display an error
>                                                 Dialog locationError = new 
> AlertDialog.Builder(
>                                                                 
> simpleGoogleMaps.this).setIcon(0).setTitle(
>                                                                 
> "Error").setPositiveButton(R.string.ok, null)
>                                                                 .setMessage(
>                                                                               
>   "Sorry, your address doesn't exist.")
>                                                                 .create();
>                                                 locationError.show();
>                                         } else { // else display address on 
> map
>                                                 for (int i = 0; i < 
> foundAdresses.size(); ++i) {
>                                                         // Save results as 
> Longitude and Latitude
>                                                         // @todo: if more 
> than one result, then show a
>                                                         // select-list
>                                                         Address x = 
> foundAdresses.get(i);
>                                                         lat = x.getLatitude();
>                                                         lon = 
> x.getLongitude();
>                                                 }
>                                                 navigateToLocation((lat * 
> 1000000), (lon * 1000000),
>                                                                 myMap); // 
> display the found address
>                                         }
>                                 } catch (Exception e) {
>                                         // @todo: Show error message
>                                 }
>
>                         }
>                 });
>         }
>
>         /**
>          * Navigates a given MapView to the specified Longitude and Latitude
>          *
>          * @param latitude
>          * @param longitude
>          * @param mv
>          */
>         public static void navigateToLocation(double latitude, double
> longitude,
>                         MapView mv) {
>                 GeoPoint p = new GeoPoint((int) latitude, (int) longitude); 
> // new
>                 // GeoPoint
>                 mv.displayZoomControls(true); // display Zoom (seems that it 
> doesn't
>                 // work yet)
>                 MapController mc = mv.getController();
>                 mc.animateTo(p); // move map to the given point
>                 int zoomlevel = mv.getMaxZoomLevel(); // detect maximum zoom 
> level
>                 mc.setZoom(zoomlevel - 1); // zoom
>                 mv.setSatellite(false); // display only "normal" mapview
>
>         }
>
> }
>
> On Feb 12, 8:49 am, Zi Yong Chua <[email protected]> wrote:
>
> > Hi guys,
>
> > I am trying to create a free app to indicate the nearest hospital/atm/
> > banks or whatever not for the city I am in. The problem i have not is
> > generating the  code to pull the location of such places. Can someone
> > enlighten me how to ask the system to search for the location, if I
> > manage to get the long/lat coordinates of the location?
>
> > Cheers
> > Zi Yong
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to