JARCH SHOWCASE
JARCH SHOWCASE
GMap - Geocode Geocoding support is provided with geocode and reverseGeocode ajax behavior events.

Geocode

Reverse Geocode

<script type="text/javascript">
    function geocode() {
        PF('geoMap').geocode(document.getElementById('address').value);
    }

    function reverseGeocode() {
        var lat = document.getElementById('lat').value,
            lng = document.getElementById('lng').value;

        PF('revGeoMap').reverseGeocode(lat, lng);
    }
</script>

<a:form prependId="false">

    <h3 style="margin-top:0">Geocode</h3>
    <h:panelGrid columns="3" style="margin-bottom:10px" cellpadding="5">
        <a:outputLabel for="address" value="Address:" />
        <a:inputText id="address" />
        <a:commandButton value="Geocode" icon="ui-icon-search" onclick="geocode()" type="button" />
    </h:panelGrid>

    <a:gmap id="geoGmap" widgetVar="geoMap" center="#{geocodeView.centerGeoMap}" zoom="2" type="ROADMAP" model="#{geocodeView.geoModel}" style="width:100%;height:400px">
        <a:ajax event="geocode" listener="#{geocodeView.onGeocode}" update="@this" />
    </a:gmap>

    <h3>Reverse Geocode</h3>
    <h:panelGrid columns="5" style="margin-bottom:10px" cellpadding="5">
        <a:outputLabel for="lat" value="Lat:" />
        <a:inputText id="lat" />
        <a:outputLabel for="lng" value="Lng:" />
        <a:inputText id="lng" />
        <a:commandButton value="Reverse Geocode" icon="ui-icon-search" onclick="reverseGeocode()" type="button"/>
    </h:panelGrid>

    <a:gmap id="revGeoGmap" widgetVar="revGeoMap" center="#{geocodeView.centerRevGeoMap}" zoom="2" type="ROADMAP" model="#{geocodeView.revGeoModel}" style="width:100%;height:400px">
        <a:ajax event="reverseGeocode" listener="#{geocodeView.onReverseGeocode}" update="@this" />
    </a:gmap>

</a:form>
                
JARCH, Copyright © 2022 All rights reserved. Running JARCH 24.3.0-SNAPSHOT on PrimeFaces-12.0.0 on Mojarra-2.3.13.