G K
G K

Reputation: 2501

Unable to view map in android app

I have used the following links code to for start up and I am unable to view my app but I have seen a grid view with lines. here the link of my code, please check and tell me.

http://pastie.org/7741576

and I followed the following links as my reference

LInk1

Link2

Link3

Upvotes: 0

Views: 718

Answers (5)

G K
G K

Reputation: 2501

finally, I got the solution what I have done mistake is that the meta_data tag is placed after the application tag, which is wrong and we have to specify before the closing tag of application tag.

like ....

and also another reason is I am using api v1 with api v2 key which it should not be done in that way. We have to use API V2 with APIV2 key.

we have to use fragment for api v2 for showing map in your app and API V2 key. thats mistake i have done and this is my code link of xml data and manifest file on how it looks like and small procedure i have learnt of my own on developing maps app

    <fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="fill_parent"
class="com.google.android.gms.maps.SupportMapFragment" />

xml design file

Manifest file

step wise procedure on how to do map app

generating near by locations and marking them on map

I hope this at least help some one who are new to develop apps.

Upvotes: 0

Vallabh Lakade
Vallabh Lakade

Reputation: 832

there can be 3 reasons for this

1) check the internet permission

2) you have used a wrong API key

3) you have not included

<uses-library android:name=”com.google.android.maps” />

Upvotes: 2

Emil Adz
Emil Adz

Reputation: 41139

You trying to implement the map using the MapView object. MapView object is a Google Maps API V1 object and it is not supported in API V2. You problem currently (without the fact that you messing the two API's together ) is that API V1 is deprecated and you can't produce a valid API key for it.

so my assumption is that you have produces this key for API V2 and trying to use it with your code which is a Google API V1 code. and this is the reason why you don't see a map.

UPDATE:

If you would like on the other hand to implement Google Map API V2, take a look at this blog post I wrote on that topic:

Google Maps API V2

For your question you would need to use MapFragment or SupportMapFragment depending on what platform you are targeting.

Upvotes: 2

moud
moud

Reputation: 759

I guess you need to add google Maps API key to your application, for this you need to add in your AndroidManifest.xml inside the application element, the following lines : <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your_api_key"/>

Upvotes: 0

jadiaz
jadiaz

Reputation: 21

You must register your key ay Google Services: 

All Maps API applications should load the Maps API using an API key. Using an API key enables you to monitor your application's Maps API usage, and ensures that Google can contact you about your application if necessary. If your application's Maps API usage exceeds the Usage Limits, you must load the Maps API using an API key in order to purchase additional quota.

To create your API key, visit the APIs Console at https://code.google.com/apis/console and log in with your Google Account.

Click the Services link from the left-hand menu, then activate the Google Maps API v2 service.

Once the service has been activated, your API key is available from the API Access page, in the Simple API Access section. Maps API applications use the Key for browser apps.

By default a key can be used on any site. We strongly recommend that you restrict use of your key only to domains you administer, to prevent use on unauthorized sites. You can specify which domains are allowed to use your API key by clicking the Edit allowed referrers... link for your key.

The your must declare permissions.

The you can do an activity with this code.   


//map Variable
private GoogleMap mMap;


//Set map
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();


//Layout
<fragment
  android:id="@+id/map"
  android:name="com.google.android.gms.maps.MapFragment"
  android:layout_width="match_parent"
  android:layout_height="match_parent" />

See this to more information http://proyectosbeta.net/2012/12/configurar-y-usar-google-maps-api-v2-para-android/

Upvotes: 1

Related Questions