Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 7769 | Rev 7772 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 7769 Rev 7771
Línea 262... Línea 262...
262
        var otherElement = $(param);
262
        var otherElement = $(param);
Línea 263... Línea 263...
263
 
263
 
264
        return $.trim(otherElement.val()).length > 0;
264
        return $.trim(otherElement.val()).length > 0;
Línea 265... Línea -...
265
    }, 'ERROR_PLACED_AUTOCOMPLETE_DOES_NOT_CONTAIN_GEOMETRY');
-
 
266
 
-
 
267
    var autocompleteLocation = new google.maps.places.Autocomplete(
-
 
268
        (document.getElementById('location_search')),
-
 
269
        {types: ['(cities)']}
-
 
270
    );
-
 
271
    
-
 
272
    $.fn.fillInAddressLocation = function() {
-
 
273
    
-
 
274
        var place = autocompleteLocation.getPlace();
-
 
275
        if (!place.geometry) {
-
 
276
            $.fn.showError('ERROR_PLACED_AUTOCOMPLETE_DOES_NOT_CONTAIN_GEOMETRY')
-
 
277
            return;
-
 
278
        } else {
-
 
279
            address1 = '';
-
 
280
            address2 = '';
-
 
281
            city1 = '';
-
 
282
            city2 = '';
-
 
283
            state = '';
-
 
284
            country = '';
-
 
285
            postal_code = '';
-
 
286
            
-
 
287
            formatted_address = place.formatted_address;
-
 
288
            latitude = place.geometry.location.lat();
-
 
289
            longitude = place.geometry.location.lng();
-
 
290
            var arrAddress = place.address_components;
-
 
291
            
-
 
292
            $.each(arrAddress, function(i, address_component) {
-
 
293
                if (address_component.types[0] == "route") {
-
 
294
                    address1 = address_component.long_name;
-
 
295
                }
-
 
296
                if (address_component.types[0] == "sublocality") {
-
 
297
                    address2 = address_component.long_name;
-
 
298
                }
-
 
299
                if (address_component.types[0] == "locality") {
-
 
300
                    city1 = address_component.long_name;
-
 
301
                }
-
 
302
                if (address_component.types[0] == "administrative_area_level_2") {
-
 
303
                    city2 = address_component.long_name;
-
 
304
                }
-
 
305
                if (address_component.types[0] == "administrative_area_level_1") {
-
 
306
                    state = address_component.long_name;
-
 
307
                }
-
 
308
                if (address_component.types[0] == "country") {
-
 
309
                    country = address_component.long_name;
-
 
310
                }
-
 
311
                if (address_component.types[0] == "postal_code") {
-
 
312
                    postal_code = address_component.long_name;
-
 
313
                }
-
 
314
            });
-
 
315
            
-
 
316
            $('#form-location #formatted_address').val(formatted_address);
-
 
317
            $('#form-location #address1').val(address1);
-
 
318
            $('#form-location #address2').val(address2);
-
 
319
            $('#form-location #city1').val(city1);
-
 
320
            $('#form-location #city2').val(city2);
-
 
321
            $('#form-location #state').val(state);
-
 
322
            $('#form-location #country').val(country);
-
 
323
            $('#form-location #postal_code').val(postal_code);
-
 
324
            $('#form-location #latitude').val(latitude);
-
 
325
            $('#form-location #longitude').val(longitude);
-
 
326
        }
-
 
327
    }
-
 
328
 
-
 
329
 
-
 
330
    var autocompleteLocationNew = new google.maps.places.Autocomplete(
-
 
331
        (document.getElementById('add_location_search')),
-
 
332
        {types: ['(cities)']}
-
 
333
    );
-
 
334
 
-
 
335
    $.fn.fillInAddressNewLocation = function() {
-
 
336
 
-
 
337
 
-
 
338
        var place = autocompleteLocationNew.getPlace();
-
 
339
        if (!place.geometry) {
-
 
340
            $.fn.showError('ERROR_PLACED_AUTOCOMPLETE_DOES_NOT_CONTAIN_GEOMETRY')
-
 
341
            return;
-
 
342
        } else {
-
 
343
            address1 = '';
-
 
344
            address2 = '';
-
 
345
            city1 = '';
-
 
346
            city2 = '';
-
 
347
            state = '';
-
 
348
            country = '';
-
 
349
            postal_code = '';
-
 
350
    
-
 
351
            formatted_address = place.formatted_address;
-
 
352
            latitude = place.geometry.location.lat();
-
 
353
            longitude = place.geometry.location.lng();
-
 
354
            var arrAddress = place.address_components;
-
 
355
                
-
 
356
            $.each(arrAddress, function(i, address_component) {
-
 
357
                if (address_component.types[0] == "route") {
-
 
358
                    address1 = address_component.long_name;
-
 
359
                }
-
 
360
                if (address_component.types[0] == "sublocality") {
-
 
361
                    address2 = address_component.long_name;
-
 
362
                }
-
 
363
                if (address_component.types[0] == "locality") {
-
 
364
                    city1 = address_component.long_name;
-
 
365
                }
-
 
366
                if (address_component.types[0] == "administrative_area_level_2") {
-
 
367
                    city2 = address_component.long_name;
-
 
368
                }
-
 
369
                if (address_component.types[0] == "administrative_area_level_1") {
-
 
370
                    state = address_component.long_name;
-
 
371
                }
-
 
372
                if (address_component.types[0] == "country") {
-
 
373
                    country = address_component.long_name;
-
 
374
                }
-
 
375
                if (address_component.types[0] == "postal_code") {
-
 
376
                    postal_code = address_component.long_name;
-
 
377
                }
-
 
378
            });
-
 
379
    
-
 
380
            $('#form-add #formatted_address').val(formatted_address);
-
 
381
            $('#form-add #address1').val(address1);
-
 
382
            $('#form-add #address2').val(address2);
-
 
383
            $('#form-add #city1').val(city1);
-
 
384
            $('#form-add #city2').val(city2);
-
 
385
            $('#form-add #state').val(state);
-
 
386
            $('#form-add #country').val(country);
-
 
387
            $('#form-add #postal_code').val(postal_code);
-
 
388
            $('#form-add #latitude').val(latitude);
-
 
389
            $('#form-add #longitude').val(longitude);
-
 
Línea 390... Línea 265...
390
        }
265
    }, 'ERROR_PLACED_AUTOCOMPLETE_DOES_NOT_CONTAIN_GEOMETRY');
391
    }
266
 
392
 
267