Skip to content

Commit a3f8368

Browse files
committed
release v0.1.15
1 parent 3403d43 commit a3f8368

File tree

6 files changed

+71
-15
lines changed

6 files changed

+71
-15
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-locationpicker-plugin",
3-
"version": "0.1.14",
3+
"version": "0.1.15",
44
"homepage": "https://github.com/Logicify/jquery-locationpicker-plugin",
55
"authors": [
66
"Dmitry Berezovsky <dmitry.berezovsky@logicify.com>"

dist/locationpicker.jquery.js

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
1-
/*! jquery-locationpicker - v0.1.14 - 2016-09-20 */
1+
/*! jquery-locationpicker - v0.1.15 - 2016-09-23 */
2+
"use strict";
3+
4+
angular.module("angular-jquery-locationpicker", []).constant("angularJQueryLocationpickerDefaultValue", {
5+
css: {
6+
width: "550px",
7+
height: "400px",
8+
"float": "left"
9+
}
10+
}).service("angularJQueryLocationpickerService", [ "angularJQueryLocationpickerDefaultValue", function(defaultValue) {
11+
var service = {};
12+
service.callAutosizeOnInit = function(element, initCb) {
13+
var cb = initCb;
14+
if (!!cb) {
15+
initCb = function() {
16+
$(element).locationpicker("autosize");
17+
cb();
18+
};
19+
} else {
20+
initCb = function() {
21+
$(element).locationpicker("autosize");
22+
};
23+
}
24+
};
25+
service.checkDefaultStyles = function(element) {
26+
var elementStyle = element[0].style;
27+
element.css({
28+
width: elementStyle.width || defaultValue.css.width,
29+
height: elementStyle.height || defaultValue.css.height,
30+
"float": elementStyle.float || defaultValue.css.float,
31+
overflow: "hidden"
32+
});
33+
};
34+
return service;
35+
} ]).directive("jqueryLocationpicker", [ "angularJQueryLocationpickerService", function(service) {
36+
return {
37+
restrict: "EA",
38+
replace: true,
39+
scope: {
40+
options: "="
41+
},
42+
link: function(scope, element, attrs) {
43+
service.checkDefaultStyles(element);
44+
service.callAutosizeOnInit(element, scope.options.oninitialized);
45+
$(element).locationpicker(scope.options);
46+
}
47+
};
48+
} ]);
49+
250
(function($) {
351
function GMapContext(domElement, options) {
452
var _map = new google.maps.Map(domElement, options);
@@ -91,6 +139,10 @@
91139
var address = GmUtility.addressByFormat(results, gmapContext.settings.addressFormat);
92140
gmapContext.locationName = address.formatted_address;
93141
gmapContext.addressComponents = GmUtility.address_component_from_google_geocode(address.address_components);
142+
} else if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
143+
return setTimeout(function() {
144+
GmUtility.updateLocationName(gmapContext, callback);
145+
}, 1e3);
94146
}
95147
if (callback) {
96148
callback.call(this, gmapContext);
@@ -148,10 +200,11 @@
148200
if (inputBinding) {
149201
if (inputBinding.radiusInput) {
150202
inputBinding.radiusInput.on("change", function(e) {
151-
if (!e.originalEvent) {
203+
var radiusInputValue = $(this).val();
204+
if (!e.originalEvent || isNaN(radiusInputValue)) {
152205
return;
153206
}
154-
gmapContext.radius = $(this).val();
207+
gmapContext.radius = radiusInputValue;
155208
GmUtility.setPosition(gmapContext, gmapContext.location, function(context) {
156209
context.settings.onchanged.apply(gmapContext.domContainer, [ GmUtility.locationFromLatLng(context.location), context.radius, false ]);
157210
});
@@ -204,21 +257,23 @@
204257
}
205258
if (inputBinding.latitudeInput) {
206259
inputBinding.latitudeInput.on("change", function(e) {
207-
if (!e.originalEvent) {
260+
var latitudeInputValue = $(this).val();
261+
if (!e.originalEvent || isNaN(latitudeInputValue)) {
208262
return;
209263
}
210-
GmUtility.setPosition(gmapContext, new google.maps.LatLng($(this).val(), gmapContext.location.lng()), function(context) {
264+
GmUtility.setPosition(gmapContext, new google.maps.LatLng(latitudeInputValue, gmapContext.location.lng()), function(context) {
211265
context.settings.onchanged.apply(gmapContext.domContainer, [ GmUtility.locationFromLatLng(context.location), context.radius, false ]);
212266
updateInputValues(gmapContext.settings.inputBinding, gmapContext);
213267
});
214268
});
215269
}
216270
if (inputBinding.longitudeInput) {
217271
inputBinding.longitudeInput.on("change", function(e) {
218-
if (!e.originalEvent) {
272+
var longitudeInputValue = $(this).val();
273+
if (!e.originalEvent || isNaN(longitudeInputValue)) {
219274
return;
220275
}
221-
GmUtility.setPosition(gmapContext, new google.maps.LatLng(gmapContext.location.lat(), $(this).val()), function(context) {
276+
GmUtility.setPosition(gmapContext, new google.maps.LatLng(gmapContext.location.lat(), longitudeInputValue), function(context) {
222277
context.settings.onchanged.apply(gmapContext.domContainer, [ GmUtility.locationFromLatLng(context.location), context.radius, false ]);
223278
updateInputValues(gmapContext.settings.inputBinding, gmapContext);
224279
});
@@ -306,7 +361,7 @@
306361
return;
307362
}
308363
var settings = $.extend({}, $.fn.locationpicker.defaults, options);
309-
var gmapContext = new GMapContext(this, {
364+
var gmapContext = new GMapContext(this, $.extend({}, settings.mapOptions, {
310365
zoom: settings.zoom,
311366
center: new google.maps.LatLng(settings.location.latitude, settings.location.longitude),
312367
mapTypeId: settings.mapTypeId,
@@ -324,7 +379,7 @@
324379
markerIcon: settings.markerIcon,
325380
markerDraggable: settings.markerDraggable,
326381
markerVisible: settings.markerVisible
327-
});
382+
}));
328383
$target.data("locationpicker", gmapContext);
329384
function displayMarkerWithSelectedArea() {
330385
GmUtility.setPosition(gmapContext, gmapContext.marker.position, function(context) {
@@ -369,6 +424,7 @@
369424
zoom: 15,
370425
mapTypeId: google.maps.MapTypeId.ROADMAP,
371426
styles: [],
427+
mapOptions: {},
372428
scrollwheel: true,
373429
inputBinding: {
374430
latitudeInput: null,

0 commit comments

Comments
 (0)