Move outer marker on change distance parameter - google-maps

I have created circle based on Pin Pivot Center & Outer Circle parameter and i have find total distance between this two points using java script.
Now what i want is when i change distance parameter my outer circle parameter should be moved with distance parameter.
So if i have change distance parameter from 200m to 300m then my outer circle pin should be moved 300m from starting point
I have attach Snap here
Any help should be appreciated.
Thanks

You can find outer circle coordinates from this:
var dest = new google.maps.geometry.spherical.computeOffset(start_point_latlng, distance, heading);
Here, heading expressed in degrees clockwise from north.(Here, you can add 180 or 90.)
You will get new coordinates of outer circle from variable p1.
For more information, see this link:
https://developers.google.com/maps/documentation/javascript/reference?csw=1#spherical

Related

Determine the position between the two positions on the map in android studio

We have two position A and B with the specified characteristics on the map.
We want to position out between these two points at a distance of 50 meters.
enter image description here
You can use the geometry library for this:
https://developers.google.com/maps/documentation/javascript/geometry
https://developers.google.com/maps/documentation/javascript/reference/3/#spherical
From the docs:
Navigation Functions
When navigating on a sphere, a heading is the angle of a direction from a fixed reference point, usually true north. Within the Google Maps API, a heading is defined in degrees from true north, where headings are measured clockwise from true north (0 degrees). You may compute this heading between two locations with the computeHeading() method, passing it two from and to LatLng objects.
Given a particular heading, an origin location, and the distance to travel (in meters), you can calculate the destination coordinates using computeOffset().
In your case you might want to get the heading first
var heading = google.maps.geometry.spherical.computeHeading(latLngFrom, latLngTo)
then you can get the offset location:
google.maps.geometry.spherical.computeOffset(latlngFrom, distance, heading)

bing maps how to get the not share square of 2 rectangle boundaries?

I am using bing maps and I want to query my database to return all values inside the map bounds, so every time, the map moves, I want to query it again.
In order to make it more efficient, I want to query only the boundary I haven't query before.
So I get the previous bound and the current bound and want to get the square bound of the non shared rectangle between the previous and the current rectangles (The not shared rectangle of the current bounds).
For example, If I move the map right for 5cm and up for 2cm, I will recieve a new LocationRect of the rectangle 5cm 2cm (the not shared).
I have the map bounds:
LocationRect currentBounds = map.Bounds;
When I move the map I get a new bounds, but before I save the previous bounds:
previousBounds = currentBounds;
I want to get the new location I moved to (only the new, not the whole currentBounds).
So I want to do something like this:
LocationRect newMapBounds = currentBounds.NotSharedBounds(previousBounds);
But how can I check this? I saw there is a method of Intersects but it returns bool, and I need to get the new LocationRect...
I will be very thankfull for the helper :)
If i understand you right you have the blue rectangle(ABCD) and when you move the map
you have red rectangle(EHGF) and you know their vertexes coordinates
e
So the not common space creating 3 new rectangles for you: Green Yellow And Black.
And you need coordinates of those 3 rectangles in order to query your data, in other words you need to perform three queries to you DB in order to get the NOT common space of BLUE and RED rectangles.
You will have scenarios of RED and BLUE rectangles that you need to deal before you start the calculations:
The rectangles are coincide.
The scenario in the picture
They have no common space at all.
For example the vertexes coordinates of GREEN rectangle are(The second scenario):
T(x) = E(x), T(y) = D(y)
F is a common of RED and GREEN Rectangles
N(x) = B(x) , N(y) = G(y)
F is a common of BLUE and GREEN Rectangles
Hope it helps.

how do i create a circle Geometry with a radius and co-ordinates of center, using MySQL Spatial Extensions?

I am trying to create a Circle Geometry in MySQL using the co-ordinates of the center and a radius. I searched everywhere...all i could find in the MySQL doc on the site were for polygons. May be i am looking in the wrong place. can anybody help me with an appropriate SQL that can help me create a table that stores this Circle geometry as one of the columns in the table?
Also, i am not even sure if there is a way to do so in MySQL?..The version i am using is MySQL 5.6.
Thanks in advance.
As of MySQL v5.6.1, you can use Buffer(g, d):
Returns a geometry that represents all points whose distance from the geometry value g is less than or equal to a distance of d.
Obviously, in your case g should be the point at the centre of the circle and d should be its radius.
There are two Parts:
A.For given tested points you have to check their relation with given circle.
B.You want to generate points on circumference of given circle.
A.Yes, First of all take the distance between your given point(test Point) and the centre of circle point. Both of these points are defined in Latitude and longitude. Distance formula between two points(x1,y1) and (x2,y2) is distance d= sqrt[ (x2-x1)^2 + (y2-y1)^2 ].
Now,
If this distance is less than radius of circle then your tested point is inside your circle.
If this distance is Greater than radius then tested point is outside the circle.
If this calculated distance is equal to radius of circle then this tested point is on your circle i.e. on the circumference of your circle.
B. In a circle the total angle theta is 360 degree or 2*Pi in radians.
For given Circle whose centre is (x1, y1) and radius is r.
x = x1 + r * cos(theta)
y = y1 + r * sin(theta)
where, theta is running from Zero to 2*Pi and Pi is 3.1415.
Depending upon how you do it. Example: if you wants 10 points on circle, then increment=(2*Pi-Zero)/10.
fist theta is zero, then theta is Zero+increment, then theta is Zero +increment+increment i.e. 2* increment and then zero + 3*increment and then so on. unless you get theta equal to 2*Pi.
For all above thetas calculate x and y. These all x and y coordinate points are on the circumference of the circle.

Moving shape within the polygon

Test link: http://bit.ly/Runmah
pick one item from left side for testing.
it's rotating when he find two intersect points on the line.
i want to move red rectangle within the polygon. It shouldn't go outside of polygon.
My code is: http://pastebin.com/pRMpk81f
Edit 1: http://pastebin.com/C3j4WSC1
If you know how to find the intersection of points on the line then you should be able to find distance between wall and furniture (line and edge of rectangle), you can check this value and for example stop draging and snap,
EDIT1:
when dragged item is selected (mouse is down) than you constantly check distance (e.g. on mouse move), then you can decide that if distance is within some threshold you will stop movement (basicaly you will set calculated position- snap - instead of applying mouse position) otherwise you will follow mouse.
EDIT2:
also you can test if the point is inside the shape by calculating intersection points - even number the point is outside, odd number - the point is inside
best regards

How do I find the angle between the center of the earth and two latitude-longitude coordinates

I've got two LatLon (latitude-longitude) objects which represent two locations on the surface of the globe. I want to find the angle (in radians) between the center of the earth and these two LatLon objects.
I'm going to use this angle and the radius of the earth to calculate the arc length between the two locations (I figure this will give better precision than using simple Pythagoras, and be faster than computing the great circle distance).
I already have code to give me the Pythagorean distance and the great circle distance.
Using something like this - how to calculate the angle between two vectors
I thought this at first (after some calc on paper) is this Pythagorean thing?
angle_between_radian = sqrt(deltaLA^2 + deltaLO^2)*PI /180
edit: delta = delta>180?360-delta:delta
We working on sphere then above must wrong ^^. But this link may help:Calculate distance, bearing and more between Latitude/Longitude points.