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.
Related
How to Get distance between coordinate on AR Location Based
I lerning from com.cobyplain.augmentreality.AugmentRealityStep4
( https://github.com/cplain/augmented-reality-tutorial )
How to show distance with mSport and mPaint on screen
http://upic.me/i/a1/dckar.png
First of all always share your code. We`re not here to give you codes but instead you help you achieve it.
If you want to show the distance between your position and some POI position that you need two things: Your position and the POI position which have both your coordinates and the POI coordinates. This can be done via manual calculation or can be done using an API.
I recommend Google Maps API for this since their function include those of which you have asked.
I am creating one google indoor map application as a part of my project. As of now i just try to create some working prototype before main application gets starts. As of now i am using one college location where i can find indoor maps available.
My main goal is show markers with windowInfo on different floors locations like rooms, theater or auditorium. I just used 1st floor one room lat long and set marker as of now. But when user switch to second floor then map should hide first floor marker and have to show other available markers on floor 2. Same thing would apply for all other floor levels.
Here, my main problem is that how can i get to know exact lat long or location of particular place on floor 2 where i should have to show marker point. Is there any way where google give response of upper floor locations with lat long or some height so i can try to determine that and show marker.
Second confusion is that when user zoom in or out or else user changes floor level at that how we can handle a lot markers hide and show.
Please share your ideas and views on this. As of now i can able to put marker on only first floor. you may find that image below.
Any help would be really appreciated.
you can use getLevels ()
Gets the levels in the building. While a level is usually enclosed by a single building, a level might be enclosed by several buildings (e.g., a carpark level might span multiple buildings). The levels are in 'display order' from top to bottom.
You can also use various methods in IndoorBuilding class getActiveLevelIndex(), getDefaultLevelIndex(),isUnderground() etc
Read more about IndoorLevel
Hope it helps
Some apps include your altitude along with your the lat/long information. What you need to do is to get your altitude and keep that as a variable. Then find out what altitude each of the levels of the building are. I am attempting to do the same thing for a University and that is the only way I knew of where you could know that you are on a second or third floor. Think of it as having your x,y, and z values. Lat/Long is basically a 2d representation of the earth's surface. But, you also have a 3rd plane. You could do the following: Download a program that not only tells you your lat/long but, also the altitude. Then have a variable that is a constant for each building. (building name) (Floor number) (Floor elevation). Then when you give the building lat/long you also give the elevation variable and then it associates it with a floor number.
Ashe
I have a program that draw a rout of user in the google map. I want to draw another rout with the data that I got from other sensors of smart phone.
how can I do that? I think I should draw a line (for each step) from specific longlot with a defined length with a angle that I got from sensors(for example magnet).
but I don't know how I can determine LongLot of the end of the line?
For showing any route on the map you need to have coordinate data in form of Latitude and Longitude. Using sensor (magnetometer) the data that you will get are the bearings in between 0 and 360 which you cannot use in map to locate a point or even a polyline.
The best thing you can do with that set of data is to create a pointer on the map that would rotate as the user holding the device changes his directions.
Please refer to this example to know about the code implementation.
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.
everyone...
I have something to ask about using a MapView in Android with Google Maps API..
I've read about how to make a Geopoint or more and find a distance between 2 points..
One thing that still makes me confuse is about calculating a distance between 2 points. I've tried and find the result but it's applied if the condition is when I want to make a straight line between those points. But, when I crosscheck with maps.google.com, the result (distance) is different with the same latitude and longitude of those points. And I realize that its a kind of a Driving Direction..
example of Google Map Web
If you see the picture, it's not a straight line so of course the distance is different. So how could I calculate this distance in Android in this case? And please show me the code to make it...
Yes it will return you the straight line distance between two point..
you can use Google direction API for this ...Here is the link for this.
http://code.google.com/apis/maps/documentation/directions/