In Gmap we can mark, desired location by passing custom latitude and longitude. Is there any way to add marker to map for user\'s CURRENT LOCATION.? Is there a way to get us
You need to figure the user's IP address and then feed it to some IP geo location tool/API in order to get the geo location in latitude/longitude. Finally use this information for your Google Map.
All JSF can do for you is giving you the user's IP address as follows:
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
String ip = request.getRemoteAddr();
// ...
If you'd like to take proxies into account as well, then check X-Forwarded-For
header:
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
String ip = request.getRemoteAddr();
String forwardedFor = request.getHeader("X-Forwarded-For");
if (forwardedFor != null) {
ip = forwardedFor.split("\\s*,\\s*", 2)[0];
}
// ...
Which IP geo location tool/API you in turn have to use is a question which you've to answer yourself. Just feed the keywords "ip geo location" to Google to get started.