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.
Related
I want to create a map for an indoor location finding App. I have images of the building layouts and how they should look, but I don't know how to show the exact location given some coordinates (X,Y). I only need something simple.
I'm creating an indoor location finding app, based on WiFi signals. The algorithm part returns a pair of coordinates (X,Y), and I want to display the location somehow.
I really don't know how I should do this.
My first thoughts were to get the pixel coordinates of the (0,0) point on the image, and the distance in pixels between two points, i.e (0,0) and (0,1), (I know they are equidistant). The image, the pixel coordinates and distance are stored in an object.
Now, given a pair (X,Y) the object above, I can calculate on which pixel the location should fall on. But this isn't MATLAB, and I'm not sure how to edit it or if I can add a Pin or something on top of the image in order to show the location.
Example:
Here is an image of a building
I know for the point (0,0)(starting from bottom left) pixel coords are (47,223) and the distance between the points is 45px.
Given the coordinates (1,2.5), I have to show the estimated location. Which is the pixel (92,110) and have to highlight it somehow.
This is my only idea, as I'm pretty new to Android developement. It doesn't necessarily have to be like this, I just want to pinpoint a location given a pair of coords (X,Y). I'm open to suggestions.
Thank you for your time.
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 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.
I have a list of start point and end point coordinates for zoned roads. When I put the coordinates in to google maps it shows the road correctly. I want to develop an android application that will alert me if I am on a zoned road.
How can I check if my current location is in the zone if I have only the start point and end point? can I use the navigation in some way?
If you want to see if a point is between two other points, the first solution that crossed my mind is as follows:
Imagine you have a triangle (point of interest, and the two end points ). If the hypotenuse is represented by the two end points, you can get the two angles that it makes with your point of interest. If both of the angles are <= 90 degrees, then the point is between them, if otherwise, it is not.
Hope this is clear.
I would like to write a app in Android where you see a pointer that always point to a certain GPS position. So when you are turning your phone or driving around the pointer will still point to the gps position.
But I have no idea how to do the calculations with the gps position and the compass sensordata.
Can anyone give me some pointers how to get started or maybe have a example of how to do this?
To achieve this you will need to know several things:
Where you want to point to.
Where you are.
What map projection you are using (metres, degrees etc)
Use the android LocationManager and register for position updates. When these updates arrive you need to extract the position and bearing (could also use compass for bearing) and convert them to the map format you are using. Commonly this will be the Google maps spherical Mercator variation.
With this information you can use trigonometry to calculate the angle between you and your tagged location and use this to draw your direction arrow on a map, or with the bearing data to tell you which way to turn.
Same starting point as above answer, but no trigonometry calculation required. Just calls of existing methods.
You have
your actual position from onLocationChanged (method of the Location class)
the coordinates (lat/lon) to point to
You can now
create an overlay on googleMaps, and draw a line from your position to the point to point to.
or if you want a shorter line (or arrow)
"bearingTo()" (again from the Location class)gives you the direction to point to. Draw a line (or arrow) and rotate it to this direction