Map can't display from sample code but can display from ap

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

Map can't display from sample code but can display from ap

Postby waertf » Wed Oct 22, 2008 6:06 pm

the code i have checked many times, pls help me, thx
enivironment:
eclipse-SDK-3.4.1-win32
android-sdk-windows-1.0_r1
jre1.6.0_07
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package com.android.MapView;
  3.  
  4.  
  5.  
  6. import com.google.android.maps.GeoPoint;
  7.  
  8. import com.google.android.maps.MapActivity;
  9.  
  10. import com.google.android.maps.MapController;
  11.  
  12. import com.google.android.maps.MapView;
  13.  
  14.  
  15.  
  16. import android.app.Activity;
  17.  
  18. import android.os.Bundle;
  19.  
  20. import android.view.ViewGroup;
  21.  
  22.  
  23.  
  24. public class MapViewActivity extends MapActivity {  
  25.  
  26.         MapView mapView;
  27.  
  28.         MapController mapController;
  29.  
  30.        
  31.  
  32.         @Override  
  33.  
  34.         public void onCreate(Bundle icicle) {  
  35.  
  36.                 super.onCreate(icicle);  
  37.  
  38.                 setContentView(R.layout.main);
  39.  
  40.                
  41.  
  42.                 mapView = (MapView) findViewById(R.id.map);
  43.  
  44.  
  45.  
  46.             ViewGroup zoom=(ViewGroup)findViewById(R.id.zoom);
  47.  
  48.             zoom.addView(mapView.getZoomControls());
  49.  
  50.            
  51.  
  52.             mapController = mapView.getController();
  53.  
  54.             mapController.setZoom(15);
  55.  
  56.             updateView();
  57.  
  58.        
  59.  
  60.         }
  61.  
  62.  
  63.  
  64.         @Override
  65.  
  66.         protected boolean isRouteDisplayed() {
  67.  
  68.                 // TODO Auto-generated method stub
  69.  
  70.                 return false;
  71.  
  72.         }  
  73.  
  74.        
  75.  
  76. private void updateView(){
  77.  
  78.                  Double lat = 1*1E6;
  79.  
  80.                  Double lng = 1*1E6;
  81.  
  82.                  
  83.  
  84.                  GeoPoint point = new GeoPoint(lat.intValue(), lng.intValue());
  85.  
  86.                  mapController.setCenter(point);
  87.  
  88.                  
  89.  
  90.         }
  91.  
  92.        
  93.  
  94. }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.      package="com.android.MapView"
  7.  
  8.      android:versionCode="1"
  9.  
  10.      android:versionName="1.0.0">
  11.  
  12.           <uses-permission android:name="android.permission.INTERNET">
  13.  
  14. <uses-permission
  15.  
  16. android:name="android.permission.ACCESS_COARSE_LOCATION" />
  17.  
  18. </uses-permission>
  19.  
  20.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  21.  
  22.         <activity android:name=".MapViewActivity"
  23.  
  24.                  android:label="@string/app_name">
  25.  
  26.             <intent-filter>
  27.  
  28.                 <action android:name="android.intent.action.MAIN" />
  29.  
  30.                 <category android:name="android.intent.category.LAUNCHER" />
  31.  
  32.             </intent-filter>
  33.  
  34.            
  35.  
  36.         </activity>
  37.  
  38.        
  39.  
  40.           <uses-library android:name="com.google.android.maps" />
  41.  
  42.     </application>
  43.  
  44.    
  45.  
  46.  
  47.  
  48.    
  49.  
  50. </manifest>
  51.  
  52.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>  
  3.  
  4.  
  5.  
  6. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  7.  
  8.        android:layout_width="fill_parent"
  9.  
  10.        android:layout_height="fill_parent">
  11.  
  12.         <com.google.android.maps.MapView android:id="@+id/map"
  13.  
  14.                android:layout_width="fill_parent"
  15.  
  16.                android:layout_height="fill_parent"
  17.  
  18.                android:apiKey="Map_Demo"
  19.  
  20.                android:clickable="true" />
  21.  
  22.         <LinearLayout android:id="@+id/zoom"
  23.  
  24.                android:layout_width="wrap_content"
  25.  
  26.                android:layout_height="wrap_content"
  27.  
  28.                android:layout_alignParentBottom="true"
  29.  
  30.                android:layout_alignParentLeft="true" />
  31.  
  32.                
  33.  
  34.                 <EditText android:layout_width="fill_parent"  
  35.  
  36.                                 android:layout_height="wrap_content"  
  37.  
  38.                                 android:text="&#36755;&#20837;&#26597;&#35810;&#22320;&#22336;?"  
  39.  
  40.                                 android:selectAllOnFocus="true"/>
  41.  
  42. </RelativeLayout>
  43.  
  44.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
Attachments
can display.jpg
can display.jpg (47.66 KiB) Viewed 1476 times
cannot display.jpg
cannot display.jpg (49.6 KiB) Viewed 1476 times
MapView.zip
my sample code
(25.26 KiB) Downloaded 150 times
waertf
Freshman
Freshman
 
Posts: 5
Joined: Wed Oct 22, 2008 5:51 pm

Top

Postby waertf » Thu Oct 23, 2008 2:56 am

solved by myself: due to didn't "Obtain a Maps API Key"
obtain a maps api key
waertf
Freshman
Freshman
 
Posts: 5
Joined: Wed Oct 22, 2008 5:51 pm

The Map can't diplay

Postby wongstar.iac » Thu Oct 23, 2008 3:34 am

How to solve the problem about "Obtain a Maps API Key"
I come across the same problem with you!
can you give me the answer?
and i put the apikey in the xml ,it isn't work!
wongstar.iac
Junior Developer
Junior Developer
 
Posts: 10
Joined: Thu Oct 23, 2008 1:17 am

Re: The Map can't diplay

Postby Jun Ji » Fri Oct 24, 2008 9:26 pm

Did you put your apikey into mapview arguments correctly??

yesterday, I generated apikey (by debug mode md5 key) and that works well.

I mean


1. get your md5 code through keytool or something

2. generate your apikey in google map api page

3. use your apikey when you make mapview



wongstar.iac wrote:How to solve the problem about "Obtain a Maps API Key"
I come across the same problem with you!
can you give me the answer?
and i put the apikey in the xml ,it isn't work!
Jun Ji
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Oct 06, 2008 10:39 am
Location: Indiana University, Bloomington

Postby Quetzalcoatl » Sat Oct 25, 2008 8:11 pm

Hi,
Sorry for the thread hijack but how do I actually go about using the generated api key with a debug application using Eclipse? As I'm currently only investigating android maps and how to use them then that's all I need at the moment.
I tried manually signing the apk file with the keytool generated keystore after I had put the api key in my xml file (application worked fine the other day before the enforcing of api keys). It didn't work after installing it on the emulator using adb.
Is there any n00b's guide to setting everything up? I seem to have managed to setup the keystore & got the api key from google but I'm thinking I must of missed something.

Cheers :D
Quetzalcoatl
Senior Developer
Senior Developer
 
Posts: 129
Joined: Sat Oct 18, 2008 8:21 pm
Location: near Manchester, UK

Re: The Map can't diplay

Postby wongstar.iac » Mon Oct 27, 2008 10:09 am

Jun Ji wrote:Did you put your apikey into mapview arguments correctly??

yesterday, I generated apikey (by debug mode md5 key) and that works well.

I mean


1. get your md5 code through keytool or something

2. generate your apikey in google map api page

3. use your apikey when you make mapview



wongstar.iac wrote:How to solve the problem about "Obtain a Maps API Key"
I come across the same problem with you!
can you give me the answer?
and i put the apikey in the xml ,it isn't work!
:)

thank you Jun Ji ,I know you means ,but I fail in first for get md5 keytool,could you give me the code how I get the MD5, and I see the http://code.google.com/android/toolbox/apis/mapkey.html but the code for generate the MD5 isn't work !please help me thank you!
wongstar.iac
Junior Developer
Junior Developer
 
Posts: 10
Joined: Thu Oct 23, 2008 1:17 am

Top

Postby Quetzalcoatl » Mon Oct 27, 2008 11:13 pm

Quetzalcoatl wrote:Hi,
Sorry for the thread hijack but how do I actually go about using the generated api key with a debug application using Eclipse? As I'm currently only investigating android maps and how to use them then that's all I need at the moment.
I tried manually signing the apk file with the keytool generated keystore after I had put the api key in my xml file (application worked fine the other day before the enforcing of api keys). It didn't work after installing it on the emulator using adb.
Is there any n00b's guide to setting everything up? I seem to have managed to setup the keystore & got the api key from google but I'm thinking I must of missed something.

Cheers :D


Sorted, down to my own inexperience with tha java signing stuff etc. Thanks to this and this I realised that I can just use the default key in debug.keystore to generate the API key. So basically all I had to do was find out the MD5 as per Plusminus' instructions and generate the api key from that and all works from Eclipse now :D
Image
Quetzalcoatl
Senior Developer
Senior Developer
 
Posts: 129
Joined: Sat Oct 18, 2008 8:21 pm
Location: near Manchester, UK

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests