darshakshah1988 / gmaps4jsf

Automatically exported from code.google.com/p/gmaps4jsf
0 stars 1 forks source link

map.getLatitude() and map.getLongitude return always the same value #203

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. move the center of the map
2. call map.getLatitude() or map.getLongitude in the backed bean

What is the expected output? What do you see instead?

Expected: The functions return the current coordinates of the map.

Instead: The functions return the initial coordinates of the map.

What version of the product are you using? On what operating system?

3.0.0
Windows 7.

Please provide any additional information below.

Code:

map.xhtml:

               <m:map id="mapa" width="1350" height="250px" latitude="40.3574" longitude="-3.55138" enableScrollWheelZoom="true" binding="#{myBean2.map}">
                <ui:repeat var="spot" value="#{myBean.spots}">
                    <m:marker latitude="#{spot.latitud}" longitude="#{spot.longitud}"/>
            </ui:repeat>
            </m:map>

                <h:commandButton value="Do something" action="#{myBean2.doSomething}"></h:commandButton>

MyBean2.java:
              private Map map; 
              (getter and setter)
              .....
              public String doSomething() {

         latitud=Float.parseFloat(map.getLatitude());
         longitud=Float.parseFloat(map.getLongitude());

                 .....

        }

Original issue reported on code.google.com by inmobil...@gmail.com on 2 Jan 2014 at 3:10

GoogleCodeExporter commented 8 years ago
You specified fixed constants for the map longitude and latitude 
(latitude="40.3574" longitude="-3.55138"). In order to update the map 
coordinates with the new values after moving the map, then you have to do the 
following:
1. Create a client listener on the map 'center_changed'.
2. Replace the map latitude and longitude current constant values with EL 
attributes.
3. In the client listener handler, re-render the map using the JSF Ajax API to 
update the map center EL values.

Original comment by Hazem.sa...@gmail.com on 17 Aug 2014 at 10:03