|
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 | + |
2 | 50 | (function($) { |
3 | 51 | function GMapContext(domElement, options) { |
4 | 52 | var _map = new google.maps.Map(domElement, options); |
|
91 | 139 | var address = GmUtility.addressByFormat(results, gmapContext.settings.addressFormat); |
92 | 140 | gmapContext.locationName = address.formatted_address; |
93 | 141 | 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); |
94 | 146 | } |
95 | 147 | if (callback) { |
96 | 148 | callback.call(this, gmapContext); |
|
148 | 200 | if (inputBinding) { |
149 | 201 | if (inputBinding.radiusInput) { |
150 | 202 | inputBinding.radiusInput.on("change", function(e) { |
151 | | - if (!e.originalEvent) { |
| 203 | + var radiusInputValue = $(this).val(); |
| 204 | + if (!e.originalEvent || isNaN(radiusInputValue)) { |
152 | 205 | return; |
153 | 206 | } |
154 | | - gmapContext.radius = $(this).val(); |
| 207 | + gmapContext.radius = radiusInputValue; |
155 | 208 | GmUtility.setPosition(gmapContext, gmapContext.location, function(context) { |
156 | 209 | context.settings.onchanged.apply(gmapContext.domContainer, [ GmUtility.locationFromLatLng(context.location), context.radius, false ]); |
157 | 210 | }); |
|
204 | 257 | } |
205 | 258 | if (inputBinding.latitudeInput) { |
206 | 259 | inputBinding.latitudeInput.on("change", function(e) { |
207 | | - if (!e.originalEvent) { |
| 260 | + var latitudeInputValue = $(this).val(); |
| 261 | + if (!e.originalEvent || isNaN(latitudeInputValue)) { |
208 | 262 | return; |
209 | 263 | } |
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) { |
211 | 265 | context.settings.onchanged.apply(gmapContext.domContainer, [ GmUtility.locationFromLatLng(context.location), context.radius, false ]); |
212 | 266 | updateInputValues(gmapContext.settings.inputBinding, gmapContext); |
213 | 267 | }); |
214 | 268 | }); |
215 | 269 | } |
216 | 270 | if (inputBinding.longitudeInput) { |
217 | 271 | inputBinding.longitudeInput.on("change", function(e) { |
218 | | - if (!e.originalEvent) { |
| 272 | + var longitudeInputValue = $(this).val(); |
| 273 | + if (!e.originalEvent || isNaN(longitudeInputValue)) { |
219 | 274 | return; |
220 | 275 | } |
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) { |
222 | 277 | context.settings.onchanged.apply(gmapContext.domContainer, [ GmUtility.locationFromLatLng(context.location), context.radius, false ]); |
223 | 278 | updateInputValues(gmapContext.settings.inputBinding, gmapContext); |
224 | 279 | }); |
|
306 | 361 | return; |
307 | 362 | } |
308 | 363 | var settings = $.extend({}, $.fn.locationpicker.defaults, options); |
309 | | - var gmapContext = new GMapContext(this, { |
| 364 | + var gmapContext = new GMapContext(this, $.extend({}, settings.mapOptions, { |
310 | 365 | zoom: settings.zoom, |
311 | 366 | center: new google.maps.LatLng(settings.location.latitude, settings.location.longitude), |
312 | 367 | mapTypeId: settings.mapTypeId, |
|
324 | 379 | markerIcon: settings.markerIcon, |
325 | 380 | markerDraggable: settings.markerDraggable, |
326 | 381 | markerVisible: settings.markerVisible |
327 | | - }); |
| 382 | + })); |
328 | 383 | $target.data("locationpicker", gmapContext); |
329 | 384 | function displayMarkerWithSelectedArea() { |
330 | 385 | GmUtility.setPosition(gmapContext, gmapContext.marker.position, function(context) { |
|
369 | 424 | zoom: 15, |
370 | 425 | mapTypeId: google.maps.MapTypeId.ROADMAP, |
371 | 426 | styles: [], |
| 427 | + mapOptions: {}, |
372 | 428 | scrollwheel: true, |
373 | 429 | inputBinding: { |
374 | 430 | latitudeInput: null, |
|
0 commit comments