|
|
|
|
@ -1,4 +1,9 @@
|
|
|
|
|
+(function($,maps){
|
|
|
|
|
if (typeof jQuery === 'undefined') {
|
|
|
|
|
throw new Error('Bootstrap\'s JavaScript requires jQuery')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
(function($, maps) {
|
|
|
|
|
$.widget("psc.googlegeocode", {
|
|
|
|
|
options: {
|
|
|
|
|
mapId: 'map',
|
|
|
|
|
@ -18,8 +23,7 @@ $.widget("psc.googlegeocode" , {
|
|
|
|
|
center: { lat: 48.862854, lng: 2.2056466 }
|
|
|
|
|
});
|
|
|
|
|
var _this = this;
|
|
|
|
|
this.element.rules("add",
|
|
|
|
|
{
|
|
|
|
|
this.element.rules("add", {
|
|
|
|
|
remote: {
|
|
|
|
|
url: 'https://maps.googleapis.com/maps/api/geocode/json',
|
|
|
|
|
type: 'get',
|
|
|
|
|
@ -37,23 +41,22 @@ $.widget("psc.googlegeocode" , {
|
|
|
|
|
.data("geoloc", item)
|
|
|
|
|
.click(function() { _this.chooseLoc('user', item) })
|
|
|
|
|
.css('cursor', 'pointer')
|
|
|
|
|
.appendTo($('#'+_this.options.locComboId));}
|
|
|
|
|
else { }
|
|
|
|
|
.appendTo($('#' + _this.options.locComboId));
|
|
|
|
|
} else {}
|
|
|
|
|
});
|
|
|
|
|
if ((data.status === 'OK') && (data.results.length == 1))
|
|
|
|
|
{
|
|
|
|
|
if ((data.status === 'OK') && (data.results.length == 1)) {
|
|
|
|
|
// _this.chooseLoc('google',data.results[0]);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
error: function()
|
|
|
|
|
{
|
|
|
|
|
error: function() {
|
|
|
|
|
// xhr, textStatus, errorThrown console.log('ajax loading error ... '+textStatus+' ... '+ errorThrown);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
chooseLoc: function(sender, loc) {
|
|
|
|
|
if (sender === 'user') this.element.val(loc.formatted_address);
|
|
|
|
|
var pos = loc.geometry.location;
|
|
|
|
|
@ -85,4 +88,4 @@ $.widget("psc.googlegeocode" , {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})(jQuery,google.maps)
|
|
|
|
|
})(jQuery, google.maps);
|