Order of polygons coordinates in android google maps - android

I am new in android. I have some issue with google map polygon. The task is to draw a polygon using 4 points. I receive current and previous coordinates from outside gps module and compute 2 offsets coordinates for each point using SphericalUtil.I need to build a polygon through 4 offset coordinates. For example i receive first, second, third, fourth. If i add these coordinates into google map in this order it shows correct.
Correct:
But if order changes, for example first, fourth, second, third, it draws like hourglass and there isn't any filling. Is there any way to draw a correct polygon independent of LatLang order?
Wrong:

Related

How to "round" GeoJSON coordinates using mapbox

I am developing a react-native-mapbox-gl app on Windows 10. I need to "round" GeoJSON points uploaded to the app so that they appear in the center of a house block. For example:
Figure 1: A marker is added on the northeaster corner of a block
Figure 2: The marker is "rounded" / "moved" to the geographical center of the block
Since it's unfeasible to manually create a GeoJSON geometry for every street there is, is there a way to achieve this?
If you encode the boundaries of a particular block as a Polygon feature, you can then use Turf.js's centroid method to calculate the center of said polygon. This will return a coordinate that can be used for the location of the marker.
If you don't have the geographic bounds of these features, one option would be to use the Mapbox Tilequery API to query for all building features within a particular radius, and then create a LatLngBounds object containing these buildings to use as the Polygon defining the boundaries of the block.

SkMaps Android - How to get lat/lng used to draw roads

I would like to use the lat/lng data used to draw roads to make my own custom routes and draw lines beside the streets (like to indicate sidewalks). Is there any functionality like getPolyline("SanFran Road") that will give me data points that I can use to draw my custom routes/lines?
You have the pointToCoordinate that returns the long/lat position relative to the screen position.
See more in the SKMapSurfaceView class.

Android Google map with inset overview when zoomed in

I am developing an android application using Google maps with clustering of markers. The application works fine however once you zoom into a specific area and all the clusters expand to individual markers I would like to also show a small view that represents the entire map, where you are, and where all the markers are, to enable the user to navigate round the map while zoomed in. Ive Googled and searched SO, but not found anything. Is there any "off the shelf" solution? Or am I going to have to code this all myself? The type of solution I am looking for is the type of small window that many games use to show an overview of where the player is and all the points of interest are within the current level.
I haven't seen any "off the shelf" solutions, but here is what I would do here:
1) Create an additional fragment of the map. Place it in one of corners like games do
2) Here is where all the magic should happen. You need to synchronize these 2 maps. Map's Projection lets you to translate geo coordinates into XY coordinates within the view. That's being said you can get lat/lng of your top-left and bottom-right corners on the main map and translate these 2 corners into top-left and bottom-right XY coordinates of the mini-map's view. Now, when you have XY coordinates, the only thing you need to do - is to draw a rect on top of the mini map.
There is even easier and more native solution - since you have top-left and bottom-right lat/lng coordinates - you can draw a set of polylines on a minimap to get a rect. But in this case it will be hard to move it around (with your finger) in case you want to change current main map location using mini-map

get location address w.r.t the polygon I am in

I have over 200 polygons to create and I get the location by LocationListenerOnChanged() but I would like to know which polygon I am in based on the current location .
How will I use LatLng to check within within each polygon every 2 miles.And how can I make the entire process faster or will android os has inbuilt function.
I checked a lot of documents related android maps v2 but I did not get any info about it.I appreciate any help w.r.t the topic .Thanks in advance.
There is no direct method in android api v2 to know if a latlng lies within a polygon. So you need to do a mathemetical calculation known as point inside polygon check. You can check out the below two methods suggested in earlier posts:
1, Raycasting method
2, Winding number method
If in your case, checking a point against all 200 or more polygons is slowing your app, you can consider reducing the number of polygons to be checked. First of all , for each polygon, other than their vertices, also store an approximate geometric center. Then when you get a new location for checking, find the distance between this location and the geometric center of all the polygons. Now take only few polygons ( say 8) whose centers are closest to the point and then do any of the above point inside polygon check for those chosen polygons.

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!
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...
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.
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 );
}
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
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.
I would do it like this,
Place a marker on the google map to indicate the position of the building
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.

Categories

Resources