[Q] Lat/long coord to pixel screen XY coord - Android Software Development

Hi guys, I need to convert the lat/long coord to pixel xy coord to show a dot on the top of some image, I know I can use the following code inside MapView to do that conversion:
mapView.getProjection().toPixels(location.getPoint(), screenCoords);
int x=screenCoords.x;
int y=screenCoords.y;
however, I don't want to show or use the MapView, I just want to extract the X and Y screen coord, because I have my own background, my app will use a simple ImageView to display that background and I want to draw a little dot on canvas, on the top of that background, that dot will only appear if that location respect some range.
To better understand the question, imagine I have an aerial photo showing some building, I know the lat/long of that building, and I want to display a dot representing the building and a second dot if my actual position is near from that local.
How I can get the XY pixel screen position of that location without showing the MapView?

Related

Android Expert Required

I want to develop an app that puts a white line grid on a black background.
The grid has 3 columns and 3 rows
There is a 10% border around the grid.
The first column takes up 50% width
The second column takes up 20% width
And the third column takes 10%width
None of the columns expand or contract, they always stay the same size.
Each row is the same height.
If you click any cell, a keyboard appears on the screen allowing you to input data into the cell.
Is it possible to do this white line grid in Android?
If yes, how does one do it?
Best regards
RedTopBox.com
anyone know
Hi All
i have not received any replies.
Can anyone help please
I think it is possible. Do you have a fixed number of rows? is it small? if yes, you could directly use LinearLayout with orientation set to horizontal for each row. There you have android:layout_weight which you can use to play with the different widths you have. For the table borders, just add a View, with a background color of your preference, again use layout_weight if necessary.
If you have too many rows, or you would prefer another approach, you could use TableLayout, and for each row a TableRow, and in the same way use layout_weight for the width. For drawing the borders you could do it in this way: http://www.droidnova.com/display-borders-in-tablelayout,112.html
TableLayout has different parameters like shrinkColumns, or stretchColumns, which you will probably would need, but I am no expert on this, so you would need to play with them.
For displaying a keyboard when the user press on each element of the table, you could have a editText on each, so this would be automatically.
BTW I recommend you asking this type of questions in stackoverflow.com, and tag it with android, there should be more capable people than me to help you with this particular case.

[Q] Live Wallpaper Backgroud

I am pretty new into android development and have a couple questions I'm sure you guys can answer pretty quickly but have so far not been able to figure out. How do I have a set background in a live wallpaper besides just creating something from canvas, I have it already loaded in the hdpi I just need to figure out how to call it. Also, is it possible to have something appear enlarge a little bit in the center of the screen then fall off the screen? I'm trying to create a time lapse of a tree where it goes through all the weather changes. Any sites you could link me too or answers you would have would be greatly appreciated. Thanks for anything you guys are able to do.
Can you be more specific? When you say background are you talking about an image file you've added as a drawable?
If you use the drawBitmap method you can draw images anywhere on a canvas.
This is roughly how I do it on my Live Wallpapers.
Code:
Bitmap background = BitmapFactory.decodeResource(getResources(), R.drawable.background);
c.drawBitmap(background, 0, 0, null);
That will draw the bitmap at the upper left most position on your canvas.
If you want your live wallpaper to slide left and right as you swipe between home screens you need to adjust the x position based on the offset. Look at the cube live wallpaper source code for more information on how to get the offset value.
What I have is a picture loaded in the hdpi file that I want to use as my background, the thing with the cube is it shows you how to draw a picture but not add one into it. I want to load in the photo and then have objects enlarge and drop down around the center of this picture. The design I'm going for is a time lapse of a tree. I was told surfaceView can set your background but I'm not sure if that's the case or not. Thanks for the reply though I appreciate it.
bearcatext said:
the thing with the cube is it shows you how to draw a picture but not add one into it.
Click to expand...
Click to collapse
It works exactly the same but instead of using c.drawLine() you use c.drawBitmap()
That makes a lot of sense thanks, and for the leaves falling would you just set the coordinates to somewhere in the middle then? Also, is there a way to have an image change color mid-screen so it looks like fall is hitting? Thanks for all your help again though.

[Q] Custom View question

Apparently XDA thinks my code is a link to an outside website ??? so it's attached in a .txt
Here's my problem. I finally figured out how to get my custom view
working, but discovered that "canvas.drawCircle(..)" draws based on
the screens dimensions and not the bitmap drawn to the canvas (I may be
misusing some terms/concepts here, still a little iffy on the whole
custom view).
Basically, I have a bitmap of a map image (decoded from a .jpg resource), and I want to be able to draw relative to the bitmap's pixel dimensions, and to the bitmap if possible, so that when it's panned/zoomed, it stays in its respective
place. Here is the code for my custom view. I x'd out my latitude and
longitude. The touch handling is code adapted from a Hello, Android
(3e) excerpt.
I'm currently working with "MAP" mode, but it will also come into
play for NAV. But I basically need to draw relative to the bitmap, which is
scaled and manipulated through the canvas(?) so that the current
location dot will stay in the same spot when the bitmap is panned or
zoomed, instead of staying in a static location based on the screen's
dimensions. Any advice?
-Mike

[Q] Map overlay trouble

Hi!
I have a problem with my Maps-application. I have the mapview in bottom in my layout, and above that a semitransparent image to give the map a specific look.
I also have a location overlay and another image overlay to mark out some interesting positions. The problem is that I don't want the semitransparent image to affect my overlay markers. They seem to be drawn directly on the map by default.
Is there a way to change something somehow so that the markers will be drawn above the semitransparent image (if they are visible on screen of course)?

Ball game - chaning ball position

I am making simple ball game and l have problem.I can't change position of Ball. I tried:
1. SetX() and setY() but lower APIs aren't supported.
2. Params and margins but when I move it left or right, the whole activity content is moving with it. Up and down moving is working fine. (Activity will have 10 ImageViews)
3. Android animations - Problem is that I can't get coorinates (getLeft(), getTop()) during the animation.
4. Canvas and draw elements - I change position of image with onDraw() and invalidate() functions but when I but backgorund and all other images (as bitmaps) it is very slow.
Can you give to me any ideas or suggestions? Thanks in advance.
Can you post the code? What do you exactly want to be done, there can be many different "ball games". You want to change the position of a bitmap or circle on the screen create x and y variables, draw bitmap or circle using them and if they change, the object will be drawn elsewhere

Categories

Resources