Move the handleAction inside the ready function. #221
This commit is contained in:
parent
3720367ae7
commit
1420493de3
1 changed files with 48 additions and 51 deletions
|
|
@ -5,7 +5,6 @@
|
|||
<script>
|
||||
|
||||
var form_in_process = false;
|
||||
var searchManager;
|
||||
var pin;
|
||||
var map;
|
||||
|
||||
|
|
@ -43,55 +42,54 @@ function GetMap()
|
|||
$('#map_lng').val(locTemp.longitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var handleAction = function() {
|
||||
var text = $.trim($('#m_gmap_address').val());
|
||||
GMaps.geocode({
|
||||
address: text,
|
||||
callback: function(results, status) {
|
||||
map.entities.clear();
|
||||
if (status == 'OK') {
|
||||
var location = results[0].geometry.location;
|
||||
var lat = location.lat();
|
||||
var lng = location.lng();
|
||||
|
||||
// show in map
|
||||
var loc = new Microsoft.Maps.Location(lat, lng);
|
||||
pin = new Microsoft.Maps.Pushpin(loc, {
|
||||
draggable: false,
|
||||
icon: '/assets/images/icon-destination.png'
|
||||
});
|
||||
|
||||
map.entities.push(pin);
|
||||
map.setView({
|
||||
center: loc
|
||||
});
|
||||
|
||||
// set value in hidden input
|
||||
$('#map_lat').val(locTemp.latitude);
|
||||
$('#map_lng').val(locTemp.longitude);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
$('#m_gmap_btn').click(function(e) {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
});
|
||||
|
||||
$("#m_gmap_address").keypress(function(e) {
|
||||
var keycode = (e.keyCode ? e.keyCode : e.which);
|
||||
if (keycode == '13') {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$(function() {
|
||||
|
||||
var handleAction = function() {
|
||||
var text = $.trim($('#m_gmap_address').val());
|
||||
GMaps.geocode({
|
||||
address: text,
|
||||
callback: function(results, status) {
|
||||
map.entities.clear();
|
||||
if (status == 'OK') {
|
||||
var location = results[0].geometry.location;
|
||||
var lat = location.lat();
|
||||
var lng = location.lng();
|
||||
|
||||
// show in map
|
||||
var loc = new Microsoft.Maps.Location(lat, lng);
|
||||
pin = new Microsoft.Maps.Pushpin(loc, {
|
||||
draggable: false,
|
||||
icon: '/assets/images/icon-destination.png'
|
||||
});
|
||||
|
||||
map.entities.push(pin);
|
||||
map.setView({
|
||||
center: loc
|
||||
});
|
||||
|
||||
// set value in hidden input
|
||||
$('#map_lat').val(lat);
|
||||
$('#map_lng').val(lng);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
$('#m_gmap_btn').click(function(e) {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
});
|
||||
|
||||
$("#m_gmap_address").keypress(function(e) {
|
||||
var keycode = (e.keyCode ? e.keyCode : e.which);
|
||||
if (keycode == '13') {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
{% if ftags.set_map_coordinate %}
|
||||
// check if we need to set map
|
||||
|
|
@ -110,8 +108,8 @@ $(function() {
|
|||
});
|
||||
|
||||
// set value in hidden input
|
||||
$('#map_lat').val(locTemp.latitude);
|
||||
$('#map_lng').val(locTemp.longitude);
|
||||
$('#map_lat').val(location.latitude);
|
||||
$('#map_lng').val(location.longitude);
|
||||
|
||||
// remove placeholder text
|
||||
$("[data-vehicle-field='1']").prop('placeholder', '');
|
||||
|
|
@ -123,7 +121,7 @@ $(function() {
|
|||
center: new Microsoft.Maps.Location({{ obj.getCoordinates.getLatitude }},
|
||||
{{ obj.getCoordinates.getLongitude }}),
|
||||
culture: 'fil-Latn'
|
||||
};
|
||||
});
|
||||
|
||||
var dest = new Microsoft.Maps.Location({{ obj.getCoordinates.getLatitude }},
|
||||
{{ obj.getCoordinates.getLongitude }});
|
||||
|
|
@ -144,5 +142,4 @@ $(function() {
|
|||
})
|
||||
);
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue