On Nov 16, 3:56 pm, dapooley <
dapoo...@gmail.com> wrote:
> For the "load", what/where is the actual data that you want to use?
> Its a marker value right?
I am not looking for when the page is loaded but instead where the map
is loaded. More specifically, where the map bounds are set.
My code so far looks like this:
<script type="text/javascript">
function setLatLong(x, y) {
document.getElementById
("LocationSelector:locx").value = x;
document.getElementById
("LocationSelector:locy").value = y;
document.getElementById("mlocation").innerHTML
=
"Latitude: " + y + " Longitude: " + x;
}
function readMarker(point) {
setLatLong(point.x, point.y);
}
function readMapCenter() {
var point = theMap.getCenter();
alert("readMapCenter Called = " + point);
setLatLong(point.x, point.y);
marker.setLatLng(point)
}
</script>
And the Map tag looks like this:
The marker is at <div id="mlocation">(not set
yet)</div></p>
<m:map width="400px" height="400px" address="#
{LocationBrowser.address}"
jsVariable="theMap" >
<m:mapControl name="GLargeMapControl"
position="G_ANCHOR_BOTTOM_RIGHT"/>
<m:eventListener eventName="moveend"
jsFunction="readMapCenter" />
<m:eventListener eventName="load"
jsFunction="readMapCenter" />
<m:marker id="marker" draggable="true"
jsVariable="marker" value="#{LocationBrowser.markerLocation}">
<m:eventListener eventName="dragend"
jsFunction="readMarker"/>
</m:marker>
</m:map>
The tags with ID locx and locy (not shown) are <inputHidden> tags.
They get updated along with the <div> tag whenever a dragend event
happens on the marker, just as advertised. Also when I drag the map
(the moveend event) the marker moved to the center and the tags get
updated.
However when the page is loaded, there is a marker placed in the
center of the map, but none of the events I have registered have yet
fired, so my inputHidden fields are left blank. There is a "load"
event for the GMap object listed in the API, but this isn't reflected
in gmaps4jsf.