Toying with MapView

by Alvin Yates » Wed, 19 Nov 2008 18:48:31 GMT


Sponsored Links
 Decided to toy with the Map API while I clean up my current app.  So I
made a simple MapView and was kinda intrigued to notice a couple
things, so I'm making sure this is default behavior and not me
breaking something:

1) Is there no default set of buttons for pan/zoom?  I had to manually
add zoom myself, but pan will be annoying.

2) My Back button does not work.  In order to quit my app, I had to
actually hit Home.  Is this normal?

--~--~---------~--~----~------------~-------~--~----~



Toying with MapView

by Mark Murphy » Wed, 19 Nov 2008 20:44:52 GMT


 


There are no buttons for pan. Make sure you have 
android:clickable="true" on the com.google.android.maps.MapView in your 
layout, and pan just works by dragging the map.


Not that I'm aware of. In the map example in my book, I didn't notice 
that the back button didn't work.

Are you overriding onKeyDown() or kin? If so, are you chaining to the 
superclass for all key events you aren't handling?

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 1.4 Published!

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Toying with MapView

by Alvin Yates » Thu, 20 Nov 2008 03:39:13 GMT


 Lovely.  I did happen to forget the super.onKeyDown() call.  And the
map dragging works just fine now.

So as far as Zoom is concerned, I have displayZoomControls() set to
true in my MapActivity.  Is there something else I need to do to get
that to appear/work as expected?





--~--~---------~--~----~------------~-------~--~----~



Toying with MapView

by Mark Murphy » Thu, 20 Nov 2008 04:37:57 GMT


 


Ah, sorry, I thought you had that working, based on your original email.

You need to actually add them to the view where you want them to go.

For example, here's a layout with a spot for the zoom controls in the 
lower-left:

<RelativeLayout xmlns:android=" http://schemas.android.com/apk/res/android" ;
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <com.google.android.maps.MapView android:id="@+id/map"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:apiKey="00yHj0k7_7vzDDmwgQLGkUa7oJbRal2t7bWIkWw"
                android:clickable="true" />
        <LinearLayout android:id="@+id/zoom"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true" />
</RelativeLayout>

Here's the piece of onCreate() code that plops the zoom controls into 
the LinearLayout shown above:

ViewGroup zoom=(ViewGroup)findViewById(R.id.zoom);
        
zoom.addView(map.getZoomControls());

If you want a full MapView project that implements all of this, head on 
over to:

 http://commonsware.com/Android/ 

and download the source code to Version 1.4. Maps/NooYawk is the project 
you're looking for inside the source ZIP.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 

Android Training on the Ranch! -- Mar 16-20, 2009
 http://www.bignerdranch.com/schedule.shtml 

--~--~---------~--~----~------------~-------~--~----~



Toying with MapView

by Alvin Yates » Fri, 21 Nov 2008 08:42:56 GMT


 Just downloaded it.  Looks pretty good, although the map doesn't
display, just the markers.  What is funny though is that when I added
in menu code to my app, it doesn't display.  However, it does display
in your app.  I'm wondering if the menu is considered an overlay?  Or
if there is yet another small item of code I am missing to put this
thing to bed.





--~--~---------~--~----~------------~-------~--~----~



Toying with MapView

by Mark Murphy » Fri, 21 Nov 2008 08:51:45 GMT


 


If you haven't done so already, you have to put in your own apiKey. I 
keep forgetting that step, since it's new.

If you look in the layout, you'll see:

android:apiKey="00yHj0k7_7vzDDmwgQLGkUa7oJbRal2t7bWIkWw"

That key won't work on your PC. If you got an apiKey for your own 
MapView app, just use it -- the key is based on the PC, not the app.

Otherwise, visit:

 http://code.google.com/android/toolbox/apis/mapkey.html 

and pick up a key.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 1.4 Published!

--~--~---------~--~----~------------~-------~--~----~



Toying with MapView

by Alvin Yates » Fri, 21 Nov 2008 08:54:00 GMT


 That explains it.  I thought it was based on the app.

*The More You Know*





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. GPS-Tracking application and telephone call

Hi,

i have a question for my app. I track gps points and i want to know
what happened, if someone call me.
I test it a little bit with the emulator. I change the location via
telnet and after I hang up, i get a toast message, that the location
has changed. But i only get the latest gps point, is that right?
So must I implement a service to save all gps points, while i am
calling??

Thanks,
Stefan
--~--~---------~--~----~------------~-------~--~----~

2. Cara rubah Magic jadi Hero

Dear all,

As subject, sorry kalo repost, tapi nyari di arsip belum nemu..
Mohon bantuannya untuk how to dan step by stepnya...

Thanks yaa..

Salam,

h|e|n|d|r|a||m|u|l|i|a|d|i|




--~--~---------~--~----~------------~-------~--~----~
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group, please visit the following page:
 

3. Android 1.6 camera gui

4. is there a way to put entire folder from "assets" to sdcard? not just individual files.

5. setting indosat M2 di G1

6. someone plz help me .. how to call built in camera app from my custom app ??

7. Not able to connect A2DP device, after connecting and disconnecting smart phone on android.