Re: [android-developers] Re: MapView Overlay problem

2011-07-01 Thread TreKing
On Fri, Jul 1, 2011 at 12:26 PM, JP  wrote:

> As a side note, I never bothered to check, I'm sure this problem has
> a record in some issues database already, where you could push a button or
> star.
>

As a matter of fact ...
http://code.google.com/p/android/issues/detail?id=3405&q=map%20view%20out%20of%20memory&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

2 years old. Given the state of the Google Maps Library, I would not hold my
breath.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2011-07-01 Thread TreKing
On Fri, Jul 1, 2011 at 11:29 AM, Felix Garcia Lainez <
fgarcialai...@gmail.com> wrote:

> I have improved the responsiveness using some of MyTrack approaches,
> but i am still getting this exception, simply doing zoom in and zoom
> out sometimes
>

I doubt there's much you can do about that - the Maps library is notoriously
buggy. I've lost count of how many workarounds I've had to employ to get it
to behave *most of the time* - and I still get the occasional crash from it
when users do crazy things like zoom or pan.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2011-07-01 Thread Kostya Vasilyev

TraceView and dmtracedump:

http://developer.android.com/guide/developing/debugging/debugging-tracing.html

01.07.2011 19:26, TreKing ?:


How should i profile this case? Really as i said there is not
any strange thing on the code... Simply a map with an overlay...


No idea. Look at the tools section in the docs and see what's 
available to you. I *think* there some kind of profiling tool, but I 
don't know for sure. If nothing else, you can throw a crude profiler 
together fairly easily to track how long a given block of code takes.


--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2011-07-01 Thread TreKing
On Fri, Jul 1, 2011 at 4:00 AM, Felix Garcia Lainez  wrote:

> So you are doing something similar to my draw method?
>

Yup - nearly identical. What I don't do is use anti-aliasing (unless it's on
be default, I don't know) or alpha. I also only use moveTo() once (first
point) and then lineTo() thereafter. I can't imagine that would make much of
a difference.


> I have just tested without alpha and anti-alising and it is faster,
> but when there is big zoom level the mapactivity is closed (i think
> this is due to memory usage)
>

Use LogCat and the debugger to make sure.

How should i profile this case? Really as i said there is not any strange
> thing on the code... Simply a map with an overlay...
>

No idea. Look at the tools section in the docs and see what's available to
you. I *think* there some kind of profiling tool, but I don't know for sure.
If nothing else, you can throw a crude profiler together fairly easily to
track how long a given block of code takes.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2011-06-30 Thread TreKing
On Thu, Jun 30, 2011 at 5:47 PM, Felix Garcia Lainez <
fgarcialai...@gmail.com> wrote:

> About the size with 300 or 400 GeoPoints i am already having problems...
> The method isOnePointVisible is an optimization i did in order to try to
> improve performance (seems to work fine).
>

So I have a very similar overlay to draw routes, with no optimization, and I
just loaded 7 or 8 of them with no apparent slow down on my Nexus One.

Here are some thoughts:
- What device are you running on?
- Are you debugging or is this in release mode?
- Do you need anti-aliasing? I think that might slow it down.
- Do you need alpha? That would definitely slow down drawing. Set that to
solid and see if if helps.

If none of that helps you're going to have to profile your code to get a
clear picture of what's taking so long.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2010-01-08 Thread TreKing
I'm still a bit confused on what you're doing, but I would suggest:

1 - Subclass ItemizedOverlay instead of Overlay to manage a collection of
similar items at once. It maintains a list OverlayItems that represent each
unique point on the map. In your case these would be the Track points you
have.

2 - In your subclass, implement Parcelable and the write method and
constructor that are required to read from / write to a Parcel. In this case
you would write out  / read back each of your OverlayItem's location.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Jan 5, 2010 at 5:47 PM, Stefan  wrote:

> hi,
> thanks for your answer :)
>
> On Jan 5, 11:30 pm, TreKing  wrote:
> > OK, well your main problem is that while you implemented the Parcelable
> > class, you didn't implement the writeToParcel method or the constructor
> that
> > takes a Parcel. That's the key.
> >
>
> in one other class of my app i has implement the parcelable to, but
> there i mustnt implement these methods. i dont know why but it works.
> this other class is my "SaveHelper" class (its like a singleton - i
> only have one object), where i save my track/route... and i test it: i
> walk around my block and i rotate the handy several times
> (==>recreation of my activity..). and after saving my gpx file i see,
> that ALL points are saved.
>
> > You need to implement the first method to save all you state information
> > (i.e., your member variables) to the Parcel object.
> > Then implement the constructor to restore your instance state from the
> > incoming Parcel object.
>
> I override my Overlay object, how you can see in my code and because
> of that i would only get the last overlay back?!?!
> I think you mean, that i do following:
>
>  @Override
>  public void writeToParcel(Parcel dest, int flags) {
>// TODO Auto-generated method stub
>  dest.writeInt( (int)gp1.getLatitude()); //something like
> that
> }
>
> and
>
> private TrackOverlay(Parcel in) {
> gp1.setLatitude(in.readInt());
> }
>
> but the onSaveInstanceState will only be called, if i pause the
> activity?! So i can only save the last to (TrackOverlay) object?!?!
> Or if i implement these methods i save all my Overlays?!?
>
> >
> > Then in your MapActivity onSavedInstanceState, iterate through all of
> your
> > Overlays and shove them into an array you can store in the Bundle.
> > In onRestoreInstanceState, get a list of Parcelables from the Bundle and
> > re-create all of your Overlays (using the constructor that takes a
> Parcel).
>
> Perhaps it is easier to save all GeoPoints in a list and in
> onSaveInstanceState() i iterate through that list and save all
> GeoPoints in a "int [] lat" and "int [] lon" array and put it to my
> bundle and in onRestoreInstanceState i read this arrays and iterate
> through these arrays  and draw the Overlays again, like:
>
> gp1.setLatitude(lat[0]); .
> for(int i= 1; i< lat.length; i++)
> {
>gp2 = gp1;
>gp1.setLatitude(..)
> ...
>   newOverlay = new TrackOverlay(gp1, gp2, MODUS);
>   map.getOverlays().add(newOverlay);
> }
> map.ivalidate();
>
>
>
> But what is more efficient and/or more elegant ?
>
> >
> > Other bit of advise: get rid of that "if (first) { /*initialze*/}" code.
> Set
> > up your MyLocationOverlay object in onCreate. If you need to have a
> starting
> > location while you wait for the first update, use getLastKnownLocation().
> >
>
> Yes, this is not the best solution and i will optimize it soon :)
>
> > I hope that makes sense and helps some.
>
> Thanks for your detailed answer.
>
> Stefan
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2010-01-05 Thread TreKing
OK, well your main problem is that while you implemented the Parcelable
class, you didn't implement the writeToParcel method or the constructor that
takes a Parcel. That's the key.

You need to implement the first method to save all you state information
(i.e., your member variables) to the Parcel object.
Then implement the constructor to restore your instance state from the
incoming Parcel object.

Then in your MapActivity onSavedInstanceState, iterate through all of your
Overlays and shove them into an array you can store in the Bundle.
In onRestoreInstanceState, get a list of Parcelables from the Bundle and
re-create all of your Overlays (using the constructor that takes a Parcel).

Other bit of advise: get rid of that "if (first) { /*initialze*/}" code. Set
up your MyLocationOverlay object in onCreate. If you need to have a starting
location while you wait for the first update, use getLastKnownLocation().

I hope that makes sense and helps some.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Jan 5, 2010 at 3:32 PM, Stefan  wrote:

> Ok, i try it :)
>
> 1. I track gps points in my app and draw my route on a MapView:
>
> @Override
> public void onLocationChanged(Location loc)
> {
>if (loc != null)
>{
>latitude = loc.getLatitude();
>longitude = loc.getLongitude();
>
>if(first)
>{
>p1 = new GeoPoint((int) (loc.getLatitude()*1E6),
> (int)
> (loc.getLongitude()*1E6));
>mc.animateTo(p1);
>mc.setZoom(18);
>first=false;
>
>//act_pos = new TrackOverlay(p1, p1,1);  I NOW USE
> MYLOCATIONOVERLAY
>//map.getOverlays().add(act_pos);
>
>mlo = new MyLocationOverlay(TRACKing.this, map);
>map.getOverlays().add(mlo);
>mlo.enableMyLocation();
>mlo.runOnFirstFix(new Runnable() {
>public void run() {
>mc.animateTo(mlo.getMyLocation());
>}  });
>}
>else
>{
>p2 = p1;
>p1 = new GeoPoint((int) (loc.getLatitude()*1E6),
> (int)
> (loc.getLongitude()*1E6));
>
>to = new TrackOverlay(p1, p2, 0);
>
>//act_pos.setGeoPoints(p1, p2);   I NOW USE
> MYLOCATIONOVERLAY
>map.getOverlays().add(to);
>mc.animateTo(p1);
>map.invalidate();
>}
>}
> }
>
> 2. My TrackOverlay class:
>
> public class TrackOverlay extends Overlay implements Parcelable
> {
>private static final int TRACK = 0;
>private GeoPoint gp1, gp2;
>private int mode;
>
>public TrackOverlay(GeoPoint gp1,GeoPoint gp2, int mode)
>{
>this.gp1 = gp1;
>this.gp2 = gp2;
>this.mode = mode;
>}
>
>public void setGeoPoints (GeoPoint gp1, GeoPoint gp2)
>{
>this.gp1 = gp1;
>this.gp2 = gp2;
>}
>
>@Override
>public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
> long when)
>{
>Projection projection = mapView.getProjection();
>if (shadow == false)
>{
>Paint paint = new Paint();
>paint.setAntiAlias(true);
>Point point = new Point();
>if(gp1!=null && gp2 != null)
>{
>projection.toPixels(gp1, point);
>
>if(mode==TRACK)
>{
>paint.setColor(Color.BLUE);
>Point point2 = new Point();
>projection.toPixels(gp2, point2);
>paint.setStrokeWidth(5);
>paint.setAlpha(120);
>canvas.drawLine(point.x, point.y,
> point2.x,point2.y, paint);
>}
>else
>  //atm nothing to do
>}
>}
>return super.draw(canvas, mapView, shadow, when);
>}
>
>@Override
>public int describeContents() {
>// TODO Auto-generated method stub
>return 0;
>}
>
>
>@Override
>public void writeToParcel(Parcel dest, int flags) {
>  

Re: [android-developers] Re: MapView Overlay problem

2010-01-05 Thread TreKing
I'm sorry, but I'm not really following or understanding what you're doing.
Could you clarify or post some sample code?

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Jan 5, 2010 at 2:35 PM, Stefan  wrote:

> On Jan 5, 6:48 pm, TreKing  wrote:
> > > Couldn't figure a way to save my overlay class to bundle
> >
> > Have your Overlay class implement the Parceable interface, which you can
> > then save to / restore from a Bundle.
> >
>
> hmmm, in my case i have always a new overlay for each line on my map:
> in every iteration/run of the onLocationChanged method i call
> overlay = new MyOverlay()
> before i know the MyLocationOverlay i draw my current location with
> the drawOval and for this overlay-object (my_pos = new MyOverlay
> (...) ) i use the parcelable.
> But i dont know how i can save my other "normal" overlays, because in
> each iteration/run i override my overlay object?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2010-01-05 Thread TreKing
>
> Couldn't figure a way to save my overlay class to bundle


Have your Overlay class implement the Parceable interface, which you can
then save to / restore from a Bundle.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Jan 5, 2010 at 6:48 AM, Stefan  wrote:

> On Jan 5, 1:16 pm, Master_Ne0 
> wrote:
> > I also had this problem, i had to save the overlay locations to the
> > outstate bundle then add them again onResume. Couldn't figure a way to
> > save my overlay class to bundle. Let me know if you find a better
> > workaround.
> >
> > Ne0
> >
>
> Thanks for your fast answer. Because this is the best idea until know,
> i will test your solution and if i find a better way, i will let you
> know.
>
> Thanks again,
> Stefan
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en