Hello !
Anyone know if there is a way to use "p:gmap" passing an address and not only the longitude and latitudes ?
Like this component of IceFaces:
http://comp-suite.icefaces.org/comp-sui ... nu&exp=map
I searched in forum and issue, but found nothing equal.
Thanks.
Use p:gmap with address.
Mojarra 2.2.x, Facelets, Glassfish V4.1, Primefaces 5.1, Eclipse Mars 1, JPA 2, EJB 3
Nei Alcantara Jr.
http://twitter.com/NeiAlcantaraJr
Nei Alcantara Jr.
http://twitter.com/NeiAlcantaraJr
-
- Posts: 1
- Joined: 18 Aug 2011, 16:01
I also am in need of such an implementation would be very cool
-
- Posts: 6144
- Joined: 10 Sep 2011, 21:10
Go to Issue 3220 in Issue Tracker, click Star (as that casts your vote for this new feature to be added to PrimeFaces, and to be updated via email about this issue/feature request).
Howard
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
Hello smithh032772
Very good. I'll vote, thanks !!
Very good. I'll vote, thanks !!
Mojarra 2.2.x, Facelets, Glassfish V4.1, Primefaces 5.1, Eclipse Mars 1, JPA 2, EJB 3
Nei Alcantara Jr.
http://twitter.com/NeiAlcantaraJr
Nei Alcantara Jr.
http://twitter.com/NeiAlcantaraJr
It would be very handsome, especially receiving geocoding informations.
But there is an jsf implementation already out there, so maybe no need to reinvent the wheel, but I did not tested it yet.
http://code.google.com/p/gmaps4jsf/
But since Google Geocoding informations should be retrievied by client and not a server (recommend by google), Javascript is the way to go here.
(Google will block you if your server has too many requests!, using client side request you can avoid this)
In my case I only use it inside an admin panel to retrieve coordinates and save them to database, so it would be handsome using it serverside.
Just call the google api and save the lat and lng in (hidden) fields which are attached to a bean.
Here extract of my function code. For better usage I have one client marker reference which is updated with new location upon a search and I pass a callback function to open a confirm dialog to confirm the found location.
Call it something like:
Maybe the now lat and lng values can be reset into center attribute of gmap for autofocus.
But there is an jsf implementation already out there, so maybe no need to reinvent the wheel, but I did not tested it yet.
http://code.google.com/p/gmaps4jsf/
But since Google Geocoding informations should be retrievied by client and not a server (recommend by google), Javascript is the way to go here.
(Google will block you if your server has too many requests!, using client side request you can avoid this)
In my case I only use it inside an admin panel to retrieve coordinates and save them to database, so it would be handsome using it serverside.
Just call the google api and save the lat and lng in (hidden) fields which are attached to a bean.
Here extract of my function code. For better usage I have one client marker reference which is updated with new location upon a search and I pass a callback function to open a confirm dialog to confirm the found location.
Code: Select all
var geocoder = new google.maps.Geocoder();
function geocodeAddress(inputAddressId, inputLatId, inputLngId, coordMaxFractDigits, map)
{
var inputAddress = document.getElementById(inputAddressId);
geocoder.geocode({'address': inputAddress.value}, function(results, status)
{
if(status == google.maps.GeocoderStatus.OK)
{
if(results.length > 0)
{
if(results.length > 1)
{
alert("Multiple addresses found for given input.")
//do something
}
//set name of address text field, direct usage
inputAddress.value = String(results[0].address_components[0].long_name);
var latLng = results[0].geometry.location;
//set lat and lng text fields
document.getElementById(inputLatId).value = round(parseFloat(latLng.lat()), coordMaxFractDigits).toLocaleString();
document.getElementById(inputLngId).value = round(parseFloat(latLng.lng()), coordMaxFractDigits).toLocaleString();
map.setCenter(latLng);
var viewport = results[0].geometry.viewport;
map.setZoom(10 - Math.round(Math.log(Math.abs(viewport.getSouthWest().lng() - viewport.getNorthEast().lng()))/Math.log(2)));
}
}
});
}
Call it something like:
Code: Select all
<h:form>
<p:gmap id="cityMap"/>
<p:inputText id="name" .../>
<h:inputHidden id="lat" .../>
<h:inputHidden id="lng" .../>
<p:commandButton ... onclick="geocodeAddress(\'#{component.parent.findComponent('name').clientId}\',
\'#{component.parent.findComponent('lat').clientId}\',
\'#{component.parent.findComponent('lng').clientId}\',
5,
#{p:widgetVar('cityMap')}.getMap())"/>
</h:form>
Maybe the now lat and lng values can be reset into center attribute of gmap for autofocus.
Last edited by djmj on 22 Jun 2012, 02:02, edited 7 times in total.
Primefaces: 11.0.0 RC2
Primefaces-Extension: 11.0.0
PrimeFaces-Mobile: 11.0
OmniFaces: 3.11
Jsf: Mojarra 2.3.8
Server: Glassfish 5.1.0
Primefaces-Extension: 11.0.0
PrimeFaces-Mobile: 11.0
OmniFaces: 3.11
Jsf: Mojarra 2.3.8
Server: Glassfish 5.1.0
-
- Posts: 6144
- Joined: 10 Sep 2011, 21:10
Thanks for sharing your code. What about using geocoder (client javascript) with p:autoComplete or p:inputText, start typing address, and geocoder does similar to p:autoComplete?djmj wrote:Here extract of my function code. For better usage I have one client marker reference which is updated with new location upon a search.
Howard
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
I don't see how that should be working, since autocomplete is using server side bean for auto suggestion.
Maybe send the Json response to the bean and populate a list, or maybe it is possible to extract just the names of all found locations. But if it is just for autocomplete feature I don't see much sense in communicating with the server.
Maybe send the Json response to the bean and populate a list, or maybe it is possible to extract just the names of all found locations. But if it is just for autocomplete feature I don't see much sense in communicating with the server.
Primefaces: 11.0.0 RC2
Primefaces-Extension: 11.0.0
PrimeFaces-Mobile: 11.0
OmniFaces: 3.11
Jsf: Mojarra 2.3.8
Server: Glassfish 5.1.0
Primefaces-Extension: 11.0.0
PrimeFaces-Mobile: 11.0
OmniFaces: 3.11
Jsf: Mojarra 2.3.8
Server: Glassfish 5.1.0
-
- Posts: 6144
- Joined: 10 Sep 2011, 21:10
That might work. Good thought/idea.
Earlier you mentioned that google recommends javascript client code, but I think I researched this, and I think I saw that REST webservice is available for geocoder, for those interested in server-side solution that could possibly populate p:autoComplete. At some point, I'd like to research this and try it. I think I bookmarked it in my Chrome browser.
Earlier you mentioned that google recommends javascript client code, but I think I researched this, and I think I saw that REST webservice is available for geocoder, for those interested in server-side solution that could possibly populate p:autoComplete. At some point, I'd like to research this and try it. I think I bookmarked it in my Chrome browser.
Howard
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Hello optimus.prime,
On the issue in 1629, says he would be ready in version 3.0, 3.0-RC1 and Future of primefaces, but have no implementation so.
You know when that will be implemented?
Thanks.
On the issue in 1629, says he would be ready in version 3.0, 3.0-RC1 and Future of primefaces, but have no implementation so.
You know when that will be implemented?
Thanks.
Mojarra 2.2.x, Facelets, Glassfish V4.1, Primefaces 5.1, Eclipse Mars 1, JPA 2, EJB 3
Nei Alcantara Jr.
http://twitter.com/NeiAlcantaraJr
Nei Alcantara Jr.
http://twitter.com/NeiAlcantaraJr
-
- Information
-
Who is online
Users browsing this forum: No registered users and 26 guests