Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create a draggable marker?
    primarykey
    data
    text
    <p>Code below it's able to create a marker.</p> <p>But I want to create a draggable marker, problem is that is not sending the click event to the server after the marker has been created. </p> <p>When the markes is created the <em>draggable</em> flag is set to true. </p> <p>Any ideas?</p> <pre class="lang-html prettyprint-override"><code>&lt;p:gmap id="gmap" center="36.890257,30.707417" zoom="13" type="HYBRID" style="width:600px;height:400px" model="#{mapBean.emptyModel}" onPointClick="handlePointClick(event);" widgetVar="map"&gt; &lt;p:ajax event="markerDrag" listener="#{mapBean.onMarkerDrag}" update="messages" /&gt; &lt;/p:gmap&gt; &lt;p:dialog widgetVar="dlg" effect="FADE" effectDuration="0.5" close="false" fixedCenter="true"&gt; &lt;h:form prependId="false"&gt; &lt;h:panelGrid columns="1"&gt; &lt;h:outputLabel value="Are you sure?"/&gt; &lt;f:facet name="footer"&gt; &lt;p:commandButton value="Yes" actionListener="#{mapBean.addMarker}" update=":messages" oncomplete="markerAddComplete()"/&gt; &lt;p:commandButton value="Cancel" onclick="return cancel()"/&gt; &lt;/f:facet&gt; &lt;/h:panelGrid&gt; &lt;h:inputHidden id="lat" value="#{mapBean.lat}"/&gt; &lt;h:inputHidden id="lng" value="#{mapBean.lng}"/&gt; &lt;/h:form&gt; &lt;/p:dialog&gt; &lt;script type="text/javascript"&gt; var currentMarker = null; function handlePointClick(event) { console.log("click event"); console.log(event.marker); if (currentMarker == null) { document.getElementById('lat').value = event.latLng.lat(); document.getElementById('lng').value = event.latLng.lng(); currentMarker = new google.maps.Marker({ position: new google.maps.LatLng(event.latLng.lat(), event.latLng.lng()) }); map.addOverlay(currentMarker); dlg.show(); } } function markerAddComplete() { //currentMarker = null; Only one can be added. dlg.hide(); } function cancel() { dlg.hide(); currentMarker.setMap(null); currentMarker = null; return false; } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload