Basic Map-Application

Tutorials that use the MapActivity. Many using GPS functionality.

Blank map application

Postby bose pandian » Tue Feb 03, 2009 2:10 pm

8) hi.. zmdea.. 8)

I had the same problem.. but now i solve it..
I write the steps to solve the problem.. hope this helps you..

Create apiKey:

C:>"C:Javajdk1.5jre1.5binkeytool.exe" -list -alias androiddebugkey -keysto
re "C:Documents and SettingsbosepandianLocal SettingsApplication DataAndroiddebug.keystore" -storepass android -keypass android

After successfully executed the command, it gives the MD5 certificate finger print.
copy that fingerprint and go to sign up for google android apikey site.
you will get the apikey and apply that key in your xml file or java file.

In the java file you apply the key like this..

myMapView = new MapView(this,"your apikey here");


AndroidManifest
In the android manifest xml file, you just give the following permission and user library.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bang.sys.maps">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<uses-sdk android:minSdkVersion="1"/>
<activity android:name=".MyMap" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

<uses-sdk> tag is optional if you are working in android version 1.0.
Hope this helps you..

Regards,
:wink: Bose.C :lol:
Last edited by bose pandian on Mon Feb 16, 2009 12:35 pm, edited 2 times in total.
bose pandian
Junior Developer
Junior Developer
 
Posts: 23
Joined: Tue Dec 30, 2008 3:46 pm
Location: bangalore

Top

SimpleMap Application

Postby bose pandian » Tue Feb 03, 2009 2:48 pm

hi.. rgesnot..

I have attached the simple map application with this post.
Follow this steps to create your apikey and apply that key in the main.xml

Go the command prompt and type the command like the following. you must type the keytool path
for ur machine and debugkeystore path for ur machine.

C:>"C:Javajdk1.5jrebinkeytool.exe" -list -alias androiddebugkey -keystore
"C:Documents and SettingsbosepandianLocal SettingsApplication DataAndroiddebug.keystore"
-storepass android -keypass android

After successfully executed the above command, you will get the result like the following.

androiddebugkey, Dec 15, 2008, keyEntry,
Certificate fingerprint (MD5): 90:1D:53:4A:D1:82:1B:F1:56:83:97:AB:27:19:FC:A3

copy your finger print and go to the following site.

sign up for google map api key

and paste the finger print in the "My certificate's MD5 fingerprint: " textbox and click the button generate api key.
It wants gmail to generate apikey so if you have gmail account type there othewise create new account and enter with that gmail account.
you will get the result like the following.

Your key is:
07c9FMKtYDjZKtuNdy9X8xdliIYxxxfd6x76F1A

This key is good for all apps signed with your certificate whose fingerprint is:

90:1D:53:4A:D1:82:1B:F1:56:83:97:AB:27:19:FC:A3

Here is an example xml layout to get you started on your way to mapping glory:

<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="07c9FMKtYDjZKtuNdy9X8xdliIY48hzs6x76F1A"
/>

finally keep save the key with you. because this one key is enough for your all map application.

If you have any doubt with this sample application, just post question below..

Hope this helps you..

Best Regards,
Bose.C
Attachments
SimpleMap.rar
Simple Map Application. U can download.
(27.29 KiB) Downloaded 650 times
bose pandian
Junior Developer
Junior Developer
 
Posts: 23
Joined: Tue Dec 30, 2008 3:46 pm
Location: bangalore

Re: SimpleMap Application

Postby saamyandroid » Fri Oct 02, 2009 2:18 pm

This Code is not working.

Getting Blank Screen.

Can u give me Working Code plz?
saamyandroid
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Sep 09, 2009 8:17 pm
Location: INDIA

Load remote KMLs on to device or emulator

Postby shyamku1718 » Mon Nov 16, 2009 9:14 pm

Hi,

We are generating KML files for the traffic data we calculated and we want to show that on the map with Green,Red and yellow lines.This works fine on Google Earth if i load the KML there.

My requirement is i have to show the same on Google Maps on the device.

************ KML Sample ***********************

<?xml version="1.0" encoding="UTF-8" standalone="no"?><kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<LookAt>
<longitude>-73.7906468706933</longitude>
<latitude>42.75665628887243</latitude>
<altitude>0.0</altitude>
<range>2003.578208227112</range>
<altitudeMode>absolute</altitudeMode>
</LookAt>
<Placemark id="linestring1">
<name>My Path</name>
<description>18.0</description>
<Style id="LineColor">
<LineStyle>
<color>ff0000ff</color>
<width>5.0</width>
</LineStyle>
</Style>
<LineString>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>-73.76177154935891,42.74131112054128
-73.76161854935891,42.74337112054128
</coordinates>
</LineString>
</Placemark>
</Document></kml>

************ END *********************************

I used the following code to load my KML

Intent mapIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("geo:0,0?q=http://10.168.6.71/kmlTesting/kmlTesting.jsp?key=DM,USA");
mapIntent.setData(uri);
startActivity(Intent.createChooser(mapIntent, "Sample Map"));

******************************************************

I get the error "This community Map cannot be loaded it contains errors"


I tried capturing a route in google Earth - saved it as KML and used that one to refer in the above piece of code but still the same error.

I have attached the real KML file also.

Could you guys please help me it's really urgent.
shyamku1718
Freshman
Freshman
 
Posts: 3
Joined: Mon Nov 16, 2009 7:01 pm

Postby jArtist » Thu Mar 11, 2010 9:30 pm

hi, thank you first..:)

I've problem through defining the map target.. I don't know why it didn't appear , I did exactly
what's described at the android.developer ,the ads-on is on the SDK installed already
I add the map external jar, but again nothing works..:?

do you have a solution for that..:)

Thank you in advance..:)
jArtist
Freshman
Freshman
 
Posts: 3
Joined: Thu Mar 11, 2010 9:02 pm

Missing com.google.android.maps.Point

Postby nicche » Thu Apr 08, 2010 9:25 am

Hi,
I've a problem importing the com.google.android.maps.Point class.

As the Build Target I'm using the Google APIs Target, platform 2.1, API level 7 within Eclipse (Galileo).
From the Eclipse Package Explorer, if I explore the maps.jar file of the Google APIs, I can see a set of classes (inside com.google.android.maps) that does not include Point. It is the same package documented in http://code.google.com/intl/it-IT/andro ... -tree.html that does not match your examples.

Furthermore, a second problem... where can I find the com.google.googlenav package?

Many thanks
nicche
nicche
Freshman
Freshman
 
Posts: 8
Joined: Thu Apr 08, 2010 8:45 am

Top

Postby nicche » Fri Apr 09, 2010 9:37 am

...OK, I realized that some examples in this site are based on old API versions.

And about the com.google.googlenav package... I wanted to use it to get route directions but I found that with newer API versions it is not possible anymore. The alternative approach is to use what is described in http://mapki.com/wiki/Google_Map_Parameters.
nicche
Freshman
Freshman
 
Posts: 8
Joined: Thu Apr 08, 2010 8:45 am

Postby Shaba1 » Mon Apr 12, 2010 12:46 am

nicche wrote:...OK, I realized that some examples in this site are based on old API versions.

And about the com.google.googlenav package... I wanted to use it to get route directions but I found that with newer API versions it is not possible anymore. The alternative approach is to use what is described in http://mapki.com/wiki/Google_Map_Parameters.


Ok nicche You stated the problem but you did not provide a solution. I am still stuck on Point not being supported. I tried google API 1.5 and 2.1 Both still say there is no such package as com.google.map.Point.
Shaba1
Freshman
Freshman
 
Posts: 5
Joined: Fri Apr 09, 2010 8:55 pm

Postby Shaba1 » Mon Apr 12, 2010 2:25 am

Ok I have read thru all 5 pages of this thread. I must say that I am not impressed. It intially looked like a pretty good basic map tutorial. One to start off with to learn the ins and outs of how android accesses and uses gps. But from the first page the code was wrong. "import com.google.android.maps.Point;" There is no such class. After reading more pages with each poster putting up his own version of the code and getting more and more confused I have just given up. The original poster has stated in a couple of post that he just does not have time( In my mind he is saying he does not give a damn) to post the correct code. He did no even post and AndroideManifest.xml with the first post so you could get the incorrect coded up on the apps menu.

Like I said I am not impressed.
Shaba1
Freshman
Freshman
 
Posts: 5
Joined: Fri Apr 09, 2010 8:55 pm

Postby nicche » Mon Apr 12, 2010 8:58 am

Shaba1, my solution was to use the GeoPoint class instead of Point, anyway it would be useful to summarize all the other fixes from the responses to the very first post of this thread in order to avoid the need of reading 5 pages for a very small example.
nicche
Freshman
Freshman
 
Posts: 8
Joined: Thu Apr 08, 2010 8:45 am

Postby Shaba1 » Mon Apr 12, 2010 5:51 pm

nicche wrote:Shaba1, my solution was to use the GeoPoint class instead of Point, anyway it would be useful to summarize all the other fixes from the responses to the very first post of this thread in order to avoid the need of reading 5 pages for a very small example.


And a proper AndroidManifest.xml file and any other xml files that you need to run the thing in the emulator would be nice.
Shaba1
Freshman
Freshman
 
Posts: 5
Joined: Fri Apr 09, 2010 8:55 pm

Re: Blank map application

Postby SamAndroid » Fri Apr 16, 2010 12:23 pm

bose pandian wrote:8) hi.. zmdea.. 8)

I had the same problem.. but now i solve it..
I write the steps to solve the problem.. hope this helps you..

Create apiKey:

C:>"C:Javajdk1.5jre1.5binkeytool.exe" -list -alias androiddebugkey -keysto
re "C:Documents and SettingsbosepandianLocal SettingsApplication DataAndroiddebug.keystore" -storepass android -keypass android

After successfully executed the command, it gives the MD5 certificate finger print.
copy that fingerprint and go to sign up for google android apikey site.
you will get the apikey and apply that key in your xml file or java file.

In the java file you apply the key like this..

myMapView = new MapView(this,"your apikey here");


AndroidManifest
In the android manifest xml file, you just give the following permission and user library.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bang.sys.maps">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<uses-sdk android:minSdkVersion="1"/>
<activity android:name=".MyMap" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

<uses-sdk> tag is optional if you are working in android version 1.0.
Hope this helps you..

Regards,
:wink: Bose.C :lol:
Sam
SamAndroid
Junior Developer
Junior Developer
 
Posts: 11
Joined: Fri Apr 02, 2010 7:48 am
Location: Pakistan

Re: Basic Map-Application

Postby aim_jeet » Sat May 22, 2010 10:58 am

HI ALL,
i have developed a map application as you described but i am still unable to see the map.
i have got map api key and internet permission is already specified but nothing happen.
when i run this programme then only grid layout and zoom in and zoom out buttons are display

my main.xml file isgiven below

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="@+id/myGMap"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="true"
android:clickable="true"
android:apiKey="0YaGLMeMFKXrhzHL-uSYZSnqXqbGwE6kxF4VwFQ"
/>

</LinearLayout>


and this is is my java file




import android.os.Bundle;
import android.view.KeyEvent;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class SampleMapActivity extends MapActivity
{

MapView myMapView = null;

MapController myMC = null;

GeoPoint geoPoint = null;

double latitude = 12.937875, longitude = 77.622313;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

myMapView = (MapView) findViewById(R.id.myGMap);
geoPoint = new GeoPoint((int) (latitude * 1000000), (int) (longitude * 1000000));
myMapView.setSatellite(false);

myMC = myMapView.getController();
myMC.setCenter(geoPoint);
myMC.setZoom(15);

myMapView.setBuiltInZoomControls(true);
myMapView.displayZoomControls(true);

}


@Override
protected boolean isRouteDisplayed()
{
return false;
}


public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_I)
{
myMapView.getController().setZoom(myMapView.getZoomLevel() + 1);
return true;
}
else if (keyCode == KeyEvent.KEYCODE_O)
{
myMapView.getController().setZoom(myMapView.getZoomLevel() - 1);
return true;
}
else if (keyCode == KeyEvent.KEYCODE_S)
{
myMapView.setSatellite(true);
return true;
}
else if (keyCode == KeyEvent.KEYCODE_M)
{
myMapView.setSatellite(false);
return true;
}
return false;
}

}

can any one help me ????
aim_jeet
Developer
Developer
 
Posts: 28
Joined: Sat May 22, 2010 8:58 am

Re: Basic Map-Application

Postby yusuf » Tue Jun 29, 2010 3:46 pm

How to import MapActivity class ?
And from where these classes come?
Code: Select all
import com.google.android.maps.MapActivity;

import com.google.android.maps.MapController;

import com.google.android.maps.MapView;

import com.google.android.maps.Point;
Androiding.........................
yusuf
Experienced Developer
Experienced Developer
 
Posts: 57
Joined: Mon Feb 15, 2010 4:25 pm
Location: Pune,India


Top
PreviousNext

Return to Map Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest