?ow to get nearest marker to my current location (Is Possible????? )

Hello,

I have a map with some markers on it. i want to develop a way that gets me back the nearest marker position to my current location.

Can someone tell me if this is possible with corona?? [import]uid: 185094 topic_id: 31880 reply_id: 331880[/import]

Should be possible and not too difficult to implement.

First use the examples here to get the current longitude and latitude:
http://docs.coronalabs.com/api/event/location/longitude.html

Then check the example here on placing markers:
http://docs.coronalabs.com/api/type/Map/addMarker.html
[import]uid: 62706 topic_id: 31880 reply_id: 127186[/import]

well… i think you didn’t understand me… what i mean is that i have many markers on a map… and i want somehow show the closest address(marker) to me… [import]uid: 185094 topic_id: 31880 reply_id: 127189[/import]

What do you mean by “nearest”? If you mean distance along a direct line between you and a marker, it shouldn’t be difficult to calculate it for each marker using latitude / longitude [and altitude if you know it] of the two points: the length of 1 degree of latitude (meridian) is the same everywhere (supposing the Earth is an ellipsoid), length of 1 degree of longitude depends on the latitude of the location (it is proportional to the cosine of latitude) but still it’s not too difficult to calculate. Then calculate the square root of the sum of squared distances by latitude, longitude and altitude.

Of course, if you mean distance along a route, it is more difficult. [import]uid: 57266 topic_id: 31880 reply_id: 127256[/import]

Should be possible and not too difficult to implement.

First use the examples here to get the current longitude and latitude:
http://docs.coronalabs.com/api/event/location/longitude.html

Then check the example here on placing markers:
http://docs.coronalabs.com/api/type/Map/addMarker.html
[import]uid: 62706 topic_id: 31880 reply_id: 127186[/import]

well… i think you didn’t understand me… what i mean is that i have many markers on a map… and i want somehow show the closest address(marker) to me… [import]uid: 185094 topic_id: 31880 reply_id: 127189[/import]

What do you mean by “nearest”? If you mean distance along a direct line between you and a marker, it shouldn’t be difficult to calculate it for each marker using latitude / longitude [and altitude if you know it] of the two points: the length of 1 degree of latitude (meridian) is the same everywhere (supposing the Earth is an ellipsoid), length of 1 degree of longitude depends on the latitude of the location (it is proportional to the cosine of latitude) but still it’s not too difficult to calculate. Then calculate the square root of the sum of squared distances by latitude, longitude and altitude.

Of course, if you mean distance along a route, it is more difficult. [import]uid: 57266 topic_id: 31880 reply_id: 127256[/import]

i mean the first one… thanks for your help… you are right maybe its not too difficult… my only problem now is how to get my current location on android devices…

local currentLocation = myMap:getUserLocation() -> this function does not work on android… it returns nil… :frowning: [import]uid: 185094 topic_id: 31880 reply_id: 127415[/import]

i mean the first one… thanks for your help… you are right maybe its not too difficult… my only problem now is how to get my current location on android devices…

local currentLocation = myMap:getUserLocation() -> this function does not work on android… it returns nil… :frowning: [import]uid: 185094 topic_id: 31880 reply_id: 127415[/import]