I get a lat long from the backend and I want to use a PNG as a map, because this map is self made. So I want to transfer my lat long on this PNG and then draw at this position a point, but I couldn't figure it out how to do...
I couldn't find it here in another question. Maybe it's so easy that no one ever asked this.
I am new to Android and new to stackoverflow :)
EDIT because of comment: The image is a self made map. It was made with ESRI cityengine and Blender. Then I made a birdseye-screenshot of the map and this screenshot I want to use as my map.
EDIT 2: #MarkusKauppinen made a good comment! So I also want to convert the lat/long to x/y coordinates of the screen (like (How do android screen coordinates work?) ). But the lat/long of my backend don't relate to the lat/long of the Earth.
Even thought that this question has a downvote and probably no one will ever see it, I could figure it out how to solve my problem.
I used this Canvas Bitmap Method to draw the map on my screen. Then I converted the lat/long coordinates so that they fit on the Screen of the mobile phone with the help of this post: How do android screen coordinates work?
With the converted lat/long coordinates then I could draw a circle on the current position on the map. Now when the coordinates change the circle is moving like it should.
Related
I'm developing an Android application (in Java/Android Studio) which receives Latitude/Longitude coordinates from a network source, which it has to plot on the screen. The appearance should be much like one of those old 'green-on-black radar screens'.
Constraints/Requirements:
The application doesn't have connection to the internet. (never)
I need to draw points, (custom) markers, lines, and polygons, all based on latitude/longitude information.
The background should be plain black. i.e. no map tiles or anything.
Does anyone know of a library which can help me achieve this?
Other options I'm considering:
Manual direct conversion to screen X/Y coordinates. This seems problematic (?) as you get closer to the poles.
Converting all points to polar coordinates (bearing/distance) from a center position. And then convert these polar coordinates to screen X/Y coordinates. Should work for the radar-style application, but seems cumbersome when there's a good library available.
I'm really interested in what you guys think and if you have suggestions on how to address this.
Thanks a million!
Kind regards,
Joost
I have been trying to make a 3rd person camera in libgdx for the past couple of days and can't seem to figure out how to do it. I have tried the rotateAround function in PerspectiveCamera, but when I move the camera to be just behind the model its suppose to follow, the rotation gets messed up. I am at a loss at what to try now. I want the camera to be set back and just above the model and to follow it. If someone could point me in the correct direction, I would greatly appreciate it.
In your render method of your game you want to update the camera to follow the player at a distance and you also want to make sure that the camera is looking at the right position either at your character or just ahead if you want to get an over the shoulder view.
Depending on the scale of your models you may have to play around with these values.
In the render loop you want something like this:
note that in this example player is a vector3 and cam is a Perspective camera
This will make the camera look at the character. You may want to modify the values to make it look ahead (Change the x and z for that).
cam.lookAt(player.x, 0, player.z);
Here we set the location of the camera so we can see that it will always be floating behind and above the character
cam.position.set(player.x, 10f, player.y-20f)
This updates the camera to apply all of your transformations
cam.update();
About rotation i'm not too sure, i've not tried it. Heres an article that should help.
I want to make an Android App, with a real map and a overlay for the map, where sprites are drawn (can be dots or small images).
This is a rather hard question, so I have made a sketch of a map of a small city, where only roads and streets can be seen. That might look something like this on the device:
Imagine the red dots to be bots, and they want to get to the yellow dot, assuming they know the position.
What Android Map API should I use to be able to:
Draw custom sprites on a given location on the map (geo-coordinates rather than screen coordinates).
Generate valid paths from the streets and roads on the map, which the dots can move on (black lines).
Use pathfinding to calculate the shortest routes, e.g. from red dot to yellow dot.
Must be able to draw more than 10 sprites on the map.
(the map doesn't have to support 3d views or street views. Plain old top-down view is just fine)
If no map API exists that does not meet these requirements, what are some other solutions?
I'm really excited about this project, but I'm having a lot of trouble getting started with it, so any help or guidance will be much appreciated.
EDIT:
It seems that there is no answer to my question. I will leave this open and report back with my own solution.
Google Maps Android API v2 and Marker class.
All valid paths? You probably should not need it if you use Android API v2 with real map drawn for you, but you can also try to use Google Directions API.
Google Directions API.
No API exist that can handle more than 10 objects. You probably need something from NASA.
Have fun coding.
I have a large PNG (around 1500 x 2000) that cut into slices and put back together using HTML because otherwise the image quality is horrible.
I want to be able to have a marker of the user's current location on this image. I'm a little lost about how to do this, especially if the image is zoomable.
Ex: How do I make the marker have variable location on the string? (codewise)
How do I know how much to change the coordinates by when they zoom in?
Help or code samples would be highly appreciated! I am very stuck.
Thanks!
Note: Please be specific, I admit I am not experienced at android development
Why not just store the marker position on the original image coordinates (x, y)? eg. if the user is in the middle, save their position as (750, 1000). When you zoom, everything is relative; so if you zoom to 2x, the full image would be 3000x4000, and the marker position would be (1500, 2000).
I don't see what your difficulty is :) maybe I'm underestimating what the problem is.
I'm trying to develop a 2D game to android using opengl.
I know how to print images on the screen and animate them. But in my game I have a map and a want to zoom in and out and scroll the map. But I can't figure out the best way of doing it.
Can anybody help me?
I don't have any api examples but I did games design at college so I'll give my two bits.
The method you use will depend on your map style, size, functionality and format.
For example if you are looking for a very static non changing map, use a simple picture image. You can use the API frame for a picture view, enabling you to zoom in and out as you do in the gallery and to scroll on zoomed images, or in this case, zoom locations on your map.
Alternatively, if your map is based off a tiling system, a good example of this is the original Pokémon and Legend of Zelda games from the old game boy, then each area stores a tile 'thumbnail' for itself as a bitmap. These are then put into their appropriate locations on a grid depending on what areas are discovered.
This is the probably the most flexible way to build your map as you are not relying on a set bitmap for the entirety your map meaning it can change its look efficiently; you can build it as desired to show areas of choice (useful for if the map only reveals places the gamer has covered) and it also means you can do tile based overlay:
ie - if a certain area should contain treasure, theres a treasure icon overlayed on that tiles x,y position on the map grid.
I used the tiling option in my game projects from college and it made everything else map related easier. It also made the map side of things smaller storage wise.
The simplest approach would be to just call glTranslatef(-scrollX,-scrollY,0) followed by glScalef(zoom,zoom,zoom) before you render your map.