0

I have made an application in android for google map using mapView api2,I have tried the folowing code.In that i have made two markers and now i want to out click events on both the marker's "snippet"....not on marker..on snippet..please help me..

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mapviewdemo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
  <uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>
  <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.mapviewdemo.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
          <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyCs4iErZHkoSk2lp_ah2XH70y0qCOaMxN8" />
    </application>

Activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

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

</RelativeLayout>

main.java

package com.example.mapviewdemo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }

}

jigar
  • 1,571
  • 6
  • 23
  • 46

1 Answers1

2

Make sure you have followed all the steps in the below link

https://developers.google.com/maps/documentation/android/start

Add the below in manifest file

 <permission
    android:name="com.example.mapviewdemo.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
 <uses-permission android:name="com.example.mapviewdemo.permission.MAPS_RECEIVE"/>

http://developer.android.com/reference/com/google/android/gms/maps/MapFragment.html

Quoting from the above doc

Use this MapFragment only if you are targeting API 12 and above. Otherwise, use SupportMapFragment.

Your min sdk is 8. You should use Support Fragment.

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

Your activity must extend FragmentActivity

SupportMapFragment fm = (SupportMapFragment)  getSupportFragmentManager().findFragmentById(R.id.map);
GoogleMap mMap = fm.getMap(); 

Make sure you have added support library

Also make sure you imported the below

import android.support.v4.app.FragmentActivity;  
import com.google.android.gms.maps.SupportMapFragment;    
Raghunandan
  • 132,755
  • 26
  • 225
  • 256
  • i am facing problem when i am trying to set the api level of google-play-service-api lib project – jigar Jun 12 '13 at 06:42
  • what is the problem you are facing? have you referred to the google play services library project in your android project? – Raghunandan Jun 12 '13 at 06:43
  • problem is whenever i click on "android" my eclipse is going to "not responding" mode...! – jigar Jun 12 '13 at 06:45
  • right click on your project. go to properties. click android and choose google api's. i guess there might be a problem with the way you have imported library project into eclipse – Raghunandan Jun 12 '13 at 07:41