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. some issue about SystemProperties.set(String key , String value)

Thanks for Mark Murphy response

for My development is not base on SDK  but all android  source code ,so I
can use this interface .

2009/8/30 Mark Murphy <mmur...@commonsware.com>




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

2. how to read values from the server using Http GET method

hi here i am sending the simple post method code

which connect to the server and read response

you can use http get in place of post method

may be this will help you

code example:

private void connectandgetresponse(final String arg_emailsStr)
{
Runnable ssr = new Runnable()
{
public void run()
{
String servResponse = "";

 // to send arguments if required
List <NameValuePair> nvps = new ArrayList <NameValuePair>();

        nvps.add(new BasicNameValuePair("arg1", Uri.encode(arg1value)));
        nvps.add(new BasicNameValuePair("arg2", Uri.encode(arg2value)));
        nvps.add(new BasicNameValuePair("arg3", Uri.encode(arg3Value))); ///
as many as wanted.....


        // connect to server and get response from server ....
     DefaultHttpClient httpclient = new DefaultHttpClient();
     HttpPost httpost   = new   HttpPost("URL to connect");
     try
        {
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
HttpResponse response = httpclient.execute(httpost);
HttpEntity my_entity = response.getEntity();
 if(null != my_entity)
{
InputStream input_Stream = my_entity.getContent();
int len = (int)my_entity.getContentLength();
if(len > 0)
{
Log.i("Length of content..","["+len+"]");
byte[] byteresp = new byte[len];
 int st_pos =  0;
int req_sz = len;
int bytes_toRead = len;
int read_cnt = 0;
while(read_cnt < bytes_toRead)
{
int read_now = 0;
if(null != input_Stream)
{
read_now = input_Stream.read(byteresp,st_pos,req_sz);
}
if(-1 == read_now)
{
break;
}
read_cnt += read_now;
st_pos   += read_now;
req_sz = bytes_toRead - read_cnt;
}
servResponse= new String(byteresp);
Log.i(getClass().getSimpleName(),"Response = ["+servResponse+"]");
}
else
{
Log.i(getClass().getSimpleName(), "No response.....");
}
}
else
{
Log.i(getClass().getSimpleName()," my_entity = NULL ");
}
}
        catch (Exception e2)
{
         e2.printStackTrace();
}

  }
};
new Thread(ssr).start();
}






-- 
Dilli Rao. M
Software Developer
www.arijasoft.com
- a pioneer in Mobile App Development

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

3. A couple of questions ADC2

4. Urgent - Setting timed expiry for application to be submitted to adc2

5. Urgent - Setting timed expiry for application to be submitted to adc2

6. glGenTextures returning 0

7. cupcake Vs donut Vs eclairs