Closed GoogleCodeExporter closed 9 years ago
Committed in revision 316.
It would be a good idea to add it to one of the samples.
Original comment by neilboyd
on 17 Aug 2010 at 8:16
for the sample - add a variable
private MyLocationOverlay mMyLocationOverlay = null;
in onCreate():
mMyLocationOverlay = new MyLocationOverlay(this, mOsmv);
mOsmv.getOverlays().add(mMyLocationOverlay);
mMyLocationOverlay.runOnFirstFix(new Runnable() {
public void run() {
mOsmv.getController().animateTo(mMyLocationOverlay.getMyLocation());
}
});
in onResume():
mMyLocationOverlay.enableCompass();
mMyLocationOverlay.enableMyLocation();
mMyLocationOverlay.followLocation(true);
and onPause():
mMyLocationOverlay.disableMyLocation();
mMyLocationOverlay.disableCompass();
Original comment by mpr....@gmail.com
on 17 Aug 2010 at 8:36
I think it's obvious how it works, but I meant to add it to one of the samples
in org.andnav.osm.samples. However I see that none of them have a
MyLocationOverlay, so that means either making a new sample or adding it to
org.andnav.osm.OpenStreetMap. So I'll go for the easy option and close this
issue without doing a sample. If anyone wants to, go ahead!
Original comment by neilboyd
on 18 Aug 2010 at 7:03
ok I'll create a new small example file!
Original comment by mpr....@gmail.com
on 18 Aug 2010 at 7:12
Here's a simple sample plus screenshot.
change the package to
package org.andnav.osm.samples;
and add an import for the MyLocationOverlay.
Original comment by mpr....@gmail.com
on 18 Aug 2010 at 5:05
Attachments:
I gave this a try on my nexus one, and when outside the compass works better
than I was expecting. One thing though, blue seemed to be pointing north, I
would have expected red to be north. Is that just me?
Original comment by bob.hage...@gmail.com
on 18 Aug 2010 at 8:05
Also, when zooming in the compass grows and moves towards the center of the
screen until the whole thing is redrawn at the next zoomlevel.
Original comment by bob.hage...@gmail.com
on 18 Aug 2010 at 9:15
regarding colors, I'm not sure where I got that information that blue points
north from ... guess that's a mistake of mine. having had a look at some
pictures, it might be good to change colors to red/black with red pointing
north.
I noticed, that the compass grows. interestingly the person icon doesn't so
Picture objects seem to behave different than Bitmaps. Maybe it's the easiest
way to create Bitmaps instead of drawing those Pictures manually ...
Original comment by mpr....@gmail.com
on 19 Aug 2010 at 6:32
I don't think the growing is anything to do with the Picture. If you do it the
same way as the person then it should work.
ie, use a member variable matrix and don't do save/restore etc.
Original comment by neilboyd
on 19 Aug 2010 at 7:29
Ok, I'll fix that tomorrow ...
Original comment by mpr....@gmail.com
on 20 Aug 2010 at 6:21
Here's a patch that fixes / changes:
- compass is only being drawn, if compass values are available
- color changed. north is now red, south black, added little white dot in the
middle
- draw direction arrow instead of PERSON if GPS provider and compass value is
available
- fixed zoom issues
Original comment by mpr....@gmail.com
on 21 Aug 2010 at 11:07
Attachments:
Could you do that as a patch instead of a diff. Then I can apply it directly.
Original comment by neilboyd
on 23 Aug 2010 at 8:35
Here's a patch file created with diff -uN ... hope that's better. I've also
added my original new file (as usual with wrong namespace etc. ...)
Original comment by mpr....@gmail.com
on 23 Aug 2010 at 4:48
Attachments:
I don't think that's right.
If bearing >= 0 it draws the compass, otherwise the person.
1. what if bearing actually is zero?
2. what if compass is disabled?
I've committed the red/blue bit in revision 319.
Original comment by neilboyd
on 24 Aug 2010 at 3:12
that's why the bearing value defaults to -1.
it can only be >= 0 if a compass value has been read ...
Original comment by mpr....@gmail.com
on 24 Aug 2010 at 3:25
Here's another update with the following changes:
- added a check, whether the orientation sensor is available or not
- show error message when enabling compass and compass not available
- removed an unnecessary check for mCompassEnabled in onSensorChanged()
- changed visibility of mContext and mMapView for classes extending
MyLocationOverlay
Original comment by mpr....@gmail.com
on 27 Aug 2010 at 8:35
Attachments:
I've committed a slightly modified version of this in revision 321.
I removed the Toast because I don't think it's worth holding on to the context
just for that. Instead enableCompass returns a boolean so that the caller can
do a Toast if he likes.
I added some comments to the code, marked with // XXX
Please get latest before doing another patch.
Original comment by neilboyd
on 27 Aug 2010 at 11:39
Hi,
you're right about the context ...
regarding your comments. it's true, that checking mAzimuth >= 0 is enough,
actually that's what I had in my previous version ... resetting the value to -1
has been missing in my latest changes, true. I don't know exactly about the >=
1 speed check. I'm not sure wether you get any bearing values if you only have
the network provider ...
here's a modified version with code changes related to your XXX comments.
Original comment by mpr....@gmail.com
on 28 Aug 2010 at 2:01
Attachments:
Committed in revision 324.
Regarding this line:
if (mLocation.hasSpeed() && mLocation.getSpeed() > 1 && mLocation.hasBearing())
{
My point was that if you have speed then it doesn't matter if it's 0 or 1. Or
alternatively maybe you're only interested if it's a slightly higher speed.
And also I imagine that you don't have bearing unless you have speed, so the
speed check might be redundant, but I haven't checked that.
I assume you don't have speed or bearing with the network provider.
Original comment by neilboyd
on 30 Aug 2010 at 9:15
Can I close this issue now?
Original comment by neilboyd
on 10 Sep 2010 at 2:40
sorry, I have been offline for a while ... yes, please close this one. If
anything's wrong with it, then it's a new bug ...
Original comment by mpr....@gmail.com
on 10 Sep 2010 at 5:06
Original comment by neilboyd
on 12 Sep 2010 at 10:01
Original issue reported on code.google.com by
mpr....@gmail.com
on 16 Aug 2010 at 6:58Attachments: