How to get longitude and latiitude from Mapcomponent in codenameone? - dictionary

How to get longitude and latiitude of the point from Mapcomponent in codenameone when user click on certain on the component ?
I have to take user's location(longitude , latitude ,...) when user double click on map and please suggest me how to do it?

You can use getCoordFromPosition(x, y) which will return a Coord object from which you can extract the lat/lon values. Notice that you can also use the new native maps API which is a bit different http://www.codenameone.com/3/post/2014/03/mapping-natively.html

Related

HERE API: How to check does (lat, lon) belong to intersection or no?

I have GPS coordinates and want to check if it's an intersection.
I'm using POST request to "https://fleet.api.here.com/2/calculateroute.json" with payload:
LATITUDE,LONGITUDE
37.775210, -122.419203
And I'm getting back response with
"INTERSECTION_CATEGORY": "0" - means "NOTAPPLICABLE".
But this point corresponds to a very big intersection in San Fransico.
Please see google-map
I checked many other points with the same result. So how can I check if it is an intersection or no?
The "INTERSECTION_CATEGORY" attribute of "LINK_ATTRIBUTE" layer is using for very specific intersections. For normally intersections the "INTERSECTION_CATEGORY" is null that means no applicable.
You can recognize if a link has intersections utilize "LINK" layer by checking attributes "REF_NODE_NEIGHBOR_LINKS"/"NON_REF_NODE_NEIGHBOR_LINKS" if one from these attributes has more than one link then it belongs to intersection, see please example for the link 576441292 on https://tcs.ext.here.com/examples/v3/pde_get_any_link_info and see please screenshot for it
Another one example to find intersections you can see on https://tcs.ext.here.com/examples/v3/find_intersection_along_route

Google map how to display a dragable marker based on coordinates and return new coordinates

I have to write a script for Google Maps V3 which will do the following:
Place a marker on a map based on a set of coordinates and possbibly change the address after the page has been loaded
Allow the user the drag the mark to replace it elsewhere
Collect the new coordinates once the marker has been moved.
The first part is basic enough and should be fine, changing the address after the page is loaded should only be a matter of calling back the same function?
I am not sure where to start on the draggable marker and collecting hew coordinates.
Would anyone know of scripts / API's or where in the doc should I start?
Have you checked the Google Maps Javascript API V3 Reference to see whether the google.maps.Marker class has :
a draggable option
an dragend event
a getPosition method
Hint: The answer might just be "yes" to all three, and you don't need much else to solve your problem.

Store Locator API + Geolocation

I am trying to create a Store Locator with the Google API, very similar to the one in the Google examples here:
http://storelocator.googlecode.com/git/examples/panel.html
However I've hit a wall trying to get the Store Locator API to get the user's position through Geolocation, so when I click on Get Direction in the infowindow I get directions to the user position; instead of having to type my address in the: Where are you? Panel box.
In the documentation what I have seen is that geolocation is a boolean in the View Option that is set to True by default. But this does not solve my problem.
Does anyone have any idea on how to do this?
seems that the googlecode page you said is no longer exist. So I can't give any further insight about what you want to make.
However, by your description, Luckily I made similar site few months ago. It is on Grocery Store Near Me .
The concept of Geolocation is an HTML5 (actually W3C) Geolocation API which is now already embed in most modern browser. It is an API which you can obtain user's location (latitude, longitude, altitude, and accuracy).
you can call it with simply
navigator.geolocation.getCurrentPosition(success, error, geo_options);
Success and error is a callback function in which you can define.
In my case, the function looks like these
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
// use the lat and long to call function to fetch an API through AJAX
fetchStoreData(latitude, longitude);
}
In the Store Locator schema (like mine in Grocery Store Near Me), Geolocation is used to obtains user lat and long. The lat and long, then send to server via AJAX to get data about nearby store location.
The server serve an API in which accept lat and long as parameter, then fetch the store data (either using database, or other external API like foursquare), then you can display it either on list, or on a maps.

Acquired the building name using GPS Coordinates

I am writing an app to use GPS coordinates obtained by the cell phone itself to retrieve the building name of that location.
For example, if I use this http URL to request with Google Place API:
https://maps.googleapis.com/maps/api/place/search/json?location=40.805112,-73.960349&radius=10&sensor=false&key="YourKey"
I can only get the street name of this coordinate through this.
But if I type "40.805112,-73.960349" in maps.google.com. I can get the exact building name. SO I was wondering how can I use Google Map API to obtain the building name I want.
Thank you very much about this!!!
The first result in the request you provided contains "name" : "Church of Notre Dame", isn't this what you are looking for?
A better request if you are only interested in the place name at this location would be to use the rankby=distance parameter instead or radius and to filter by type=establishment:
https://maps.googleapis.com/maps/api/place/search/json?location=40.805112,-73.960349&rankby=distance&types=establishment&sensor=false&key=YOUR_API_KEY
This would return the closest place at the given location.

Detect nearest location from Array of Locations by using Google Map APIs

I've an array of locations: {'place1', 'place2', 'place3'} *// these are addresses
Now assume that there is a new location: 'place4'.
I want to detect which one is nearest to 'place4'....comparing from above array of locations....
i.e. tracking nearest location of a point from array of locations...(By using Google Map APIs)..
psuedo code:
foreach(var item in array)
{
var i = TrackNearestLocationByGoogleMapAPIs(item);
if(i is nerest)
{
print(i); and go out of loop...
}
}
There is no API-call to do what you want. You have to calculate the distance yourself with the Haversine formula as seen here: http://www.movable-type.co.uk/scripts/latlong.html
I don't think Google Maps API v3 provides a simple mechanism to do this. You might be able to retrieve the latitude and longitude of each location and figure out which point is the closest from that data.

Resources