Re: [android-developers] Custom Navigator app questions

2010-11-18 Thread TreKing
On Sun, Nov 14, 2010 at 8:05 PM, Mikey  wrote:

> Here's my first issue. With this implementation, the user is able to pan
> the picture out of the screen or zoom out until it only takes up a pixel
> or two. Is there any better implementation that will not allow the user to
> pan beyond the borders of the image or zoom out past the image size?
>

For zooming, determine the max and min zoom levels you want to allow and
don't allow going past that.
For panning, as the image is panned, detect when been moved as much as it
can, then force the location back to that point. So if the left edge has
been panned to the right farther than the left of the screen, force the left
edge back to the left of the screen. Same idea for the other edges.

My question is, since I'm using an ImageView to put the png in, how can I
> draw on this?
>

Derive from ImageView, call super.onDraw() (or super.draw(), I forget), to
do the default image drawing, then draw your circle as required.


> I've been searching around all day and it appears that Canvas would be the
> ideal way, since you can call drawCircle(x, y, radius, paint). However, I
> was unable to find a way to correlate an ImageView to a Canvas and back.
>

The draw function gets a canvas - draw on that.

-
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

[android-developers] Custom Navigator app questions

2010-11-17 Thread Mikey
Here's a quick background on my situation. I'm a college student and
for my thesis project I've decided to develop a "campus navigator" app
to assist incoming students in getting acquainted with the campus.
This is a year long project so at this point I'm partially
troubleshooting and partially trying to find out if my ideas are going
to run me into walls later down the road.

So as not to have an overwhelmingly long post, I'll just ask about my
current issues for now. The app opens up and allows the user to select
"Map" or "Navigate". I started working with map first because it
should be significantly simpler.

Current State:
The following currently works: hitting the map button displays a .png
of my campus's map (located at http://www.brockport.edu/about/maps/suny.html).
I've cropped the picture to only show the numbered buildings (i.e. the
oval track at the bottom, erie canal along the top, and blank spaces
on left/right near streets are all removed). The resulting image is
923x630.

Using the multi-touch pan/zoom code from Hello, Android! (3rd Edition)
(source code folder Touchv2 available at book's website), the map
display page allows the user to pinch zoom and pan the image. Here's
my first issue. With this implementation, the user is able to pan the
picture out of the screen or zoom out until it only takes up a pixel
or two. Is there any better implementation that will not allow the
user to pan beyond the borders of the image or zoom out past the image
size?

This feeds into my next issue, the "Where I want to be" part. Ideally,
I'd like the map display to use a location manager, and upon location
change, draw a circle where the user is standing. As far as projecting
latitude/longitude to pixel coordinates on the campus.png, that's just
math and I can figure that part out. My question is, since I'm using
an ImageView to put the png in, how can I draw on this? I've been
searching around all day and it appears that Canvas would be the ideal
way, since you can call drawCircle(x, y, radius, paint). However, I
was unable to find a way to correlate an ImageView to a Canvas and
back. On top of this, I need it to base these draws solely on
the .png's pixel coordinates, not the current display (since the image
may be panned or zoomed somewhere that would affect this).

I know it would be simple to just use Google Maps to implement this,
but if possible I'd strongly prefer to use the campus map, as it
clearly depicts all the walkways and buildings on the campus.

Any suggestions/help would be greatly appreciated. I just wanted to
ask early on so I don't make a fatal mistake and have to redesign it a
month before it's due. If you want to see any of my code, just let me
know.

-Mikey

-- 
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