Peter
Peter

Reputation: 5121

Android custom GPS map application

I want to build an app that uses GPS data and a building map I provide to show the user where in the building on the map they are. This will be done in a specific building that i already know gets GPS and cell service.

At first I thought the easiest way to do this was to see if I could use Google maps to plot the users location and then just "overlay" my custom building map on top of the Google map so that I wouldnt have to deal with any of the gps information or the complexities of the mapping I would just have to scale my "overlay" to fit properly on top of the Google map so that the user was shown in the correct room in a building. I'm wondering if anyone can provide me any information on how to do this or if there is an easier way to accomplish my map. Any information at all is helpful!

Upvotes: 3

Views: 5676

Answers (6)

railwayparade
railwayparade

Reputation: 5156

I would do it like this,

  1. Place a marker on the google map to indicate the position of the building

  2. Drilling down on the building would load your building map as a custom view. Plot the user location on the custom view

I think trying to overlay your building map on a google map while possible will be more complex to code than doing it via a custom view.

Also overlaying the lowest zoom level with your building map is not going to give you enough resolution unless you have a thumping big building. Whole blocks are pretty small

One issue you have probably already considered is the device will revert to cell tower and wifi for it's location when inside the building giving you a less accurate location fix.

Upvotes: 0

ScouseChris
ScouseChris

Reputation: 4397

You may be able to achieve this with a custom view that displays your building plan and knows the precise co-ordinates of each corner of the building.

When you receive your location updates you can add a marker to your custom view by translating the real world position into a position in the image using something along the lines of:

pseudocode:

markerX = realWorldX - mapStartX;
markerY = realWorldY - mapStartY;

if( isOnMap( markerX, markerY ) )
{
    drawMarker( markerX, markerY );
}

Upvotes: 1

sast
sast

Reputation: 478

If you need only the map of the building, it should not be too difficult to plot the location on an image without using Google Maps, provided that you can determine your location as coordinates inside the building.

You need to know two coordinates: north-west and south-east corners of the building map you are using. When you get GPS location updates, the correct location on the map image can be easily calculated based on these corner coordinates.

Upvotes: 0

Maurice Lam
Maurice Lam

Reputation: 354

Yes you can overlay bitmap images on top of the Google MapView.

All you have to do is subclass the Overlay class, override the draw method, and draw on the canvas. You have to provide a rectangle of GeoPoints (probably the top left and the bottom right corners) to anchor the building bitmap on top of the MapView. You use mapView.getProjection() to translate the latitude and longitude into xy coordinates on the canvas.

I assume drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) will be useful here. Bear in mind that src and paint can be null. If the GeoPoints you used are accurate, the bitmap will adjust automatically to pans and zooms, although it might get pixelated if the user zooms in too much.

edit: I am not so confident that Google Maps will have your building stays at the exact same GeoPoints in different zoom levels, so you might have to adjust those values for different zoom levels

Upvotes: 0

piotrpo
piotrpo

Reputation: 12636

There is no possibility to use closer zoom level than that you can see on standard GMap i.e. in browser. Other problem is that google uses GeoPoint class based on cardinal microdegrees to draw overlays, and it's accuracy is to low. You can look on jGarminImg - it's java library - unfortunately written for using with swing, but it should be relatively easy to make it work with android. On the other hand - you have to make your own map. You can use standard overlays, or you can make your map in kml format and use this example to display it.

Upvotes: 1

rf43
rf43

Reputation: 4405

You want... Google Map View

...and more specifically you will probably want to read the subsection appropriately titled: "Part 2: Adding Overlay Items"

EDIT: Whoops! Nevermind! I misread your question... that is only if you want to overlay an item on the map. Sorry...

Upvotes: 1

Related Questions