- Posts: 3
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
$('input[id="answer{SGQ}"]').change(function() { // code });
document.getElementById('gmap_canvas_SSSSSSXGGXQQ_c').click(function() { //code });
$(document).ready()
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ window.setTimeout(function() { // A little time for the map to initialize var mapSGQA = {SGQ}; // Define the map and marker var currentMap = gmaps[''+mapSGQA+'_c']; var currentMarker = gmaps['marker__'+mapSGQA+'_c']; // Listener on the map "click" event google.maps.event.addListener(currentMap, 'click', function() { alert(currentMarker.getPosition()); }); }, 1000); }); </script>
var mapSGQA = '{SGQ}';
<input id="search_address" type="text" value="" /><button onclick="search()">Search</button> <script type="text/javascript"> var addressField = document.getElementById('search_address'); var geocoder = new google.maps.Geocoder(); function search() { geocoder.geocode( { 'address': addressField.value }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var loc = results[0].geometry.location; // use loc.lat(), loc.lng() alert(loc.lat()); } else { alert("Not found: " + status); } } ); }; </script>
Well, you did ask for an "Onclick" event listener. You can also use the "dragend" and "rightclick" events....generally they'd either scroll right to the desired location and Drag the marker to there (doesn't count for the Click event) or they'd Right Click to place the marker at the desired location...
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ window.setTimeout(function() { // A little time for the map to initialize var mapSGQA = '{SGQ}'; // Define the map and marker var currentMap = gmaps[''+mapSGQA+'_c']; var currentMarker = gmaps['marker__'+mapSGQA+'_c']; google.maps.event.addListener(currentMarker, 'dragend', function() { alert(currentMarker.getPosition()); }); google.maps.event.addListener(currentMap, 'rightclick', function() { alert(currentMarker.getPosition()); }); }, 1000); }); </script>