Move the handleAction inside the ready function. #221

This commit is contained in:
Korina Cordero 2019-06-18 03:26:45 +00:00
parent 3720367ae7
commit 1420493de3

View file

@ -5,7 +5,6 @@
<script> <script>
var form_in_process = false; var form_in_process = false;
var searchManager;
var pin; var pin;
var map; var map;
@ -43,9 +42,11 @@ function GetMap()
$('#map_lng').val(locTemp.longitude); $('#map_lng').val(locTemp.longitude);
} }
} }
} };
var handleAction = function() { $(function() {
var handleAction = function() {
var text = $.trim($('#m_gmap_address').val()); var text = $.trim($('#m_gmap_address').val());
GMaps.geocode({ GMaps.geocode({
address: text, address: text,
@ -69,28 +70,25 @@ var handleAction = function() {
}); });
// set value in hidden input // set value in hidden input
$('#map_lat').val(locTemp.latitude); $('#map_lat').val(lat);
$('#map_lng').val(locTemp.longitude); $('#map_lng').val(lng);
} }
}, },
}); });
} };
$('#m_gmap_btn').click(function(e) { $('#m_gmap_btn').click(function(e) {
e.preventDefault(); e.preventDefault();
handleAction(); handleAction();
}); });
$("#m_gmap_address").keypress(function(e) { $("#m_gmap_address").keypress(function(e) {
var keycode = (e.keyCode ? e.keyCode : e.which); var keycode = (e.keyCode ? e.keyCode : e.which);
if (keycode == '13') { if (keycode == '13') {
e.preventDefault(); e.preventDefault();
handleAction(); handleAction();
} }
}); });
$(function() {
{% if ftags.set_map_coordinate %} {% if ftags.set_map_coordinate %}
@ -110,8 +108,8 @@ $(function() {
}); });
// set value in hidden input // set value in hidden input
$('#map_lat').val(locTemp.latitude); $('#map_lat').val(location.latitude);
$('#map_lng').val(locTemp.longitude); $('#map_lng').val(location.longitude);
// remove placeholder text // remove placeholder text
$("[data-vehicle-field='1']").prop('placeholder', ''); $("[data-vehicle-field='1']").prop('placeholder', '');
@ -123,7 +121,7 @@ $(function() {
center: new Microsoft.Maps.Location({{ obj.getCoordinates.getLatitude }}, center: new Microsoft.Maps.Location({{ obj.getCoordinates.getLatitude }},
{{ obj.getCoordinates.getLongitude }}), {{ obj.getCoordinates.getLongitude }}),
culture: 'fil-Latn' culture: 'fil-Latn'
}; });
var dest = new Microsoft.Maps.Location({{ obj.getCoordinates.getLatitude }}, var dest = new Microsoft.Maps.Location({{ obj.getCoordinates.getLatitude }},
{{ obj.getCoordinates.getLongitude }}); {{ obj.getCoordinates.getLongitude }});
@ -144,5 +142,4 @@ $(function() {
}) })
); );
{% endfor %} {% endfor %}
{% endif %} {% endif %}