From b76b2fd392d0ffbd09c451ae224ee2323d50d885 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 30 Aug 2018 08:47:56 -0400 Subject: [PATCH] Updating the geocode for city issue City field is being sent over to geocoder with huge amounts of untrimed spaces. --- views/admin/events/edit.html | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/views/admin/events/edit.html b/views/admin/events/edit.html index 07e07c3..ed0a62d 100755 --- a/views/admin/events/edit.html +++ b/views/admin/events/edit.html @@ -167,8 +167,8 @@ {foreach $event.fieldRequired as $fieldName => $fValue} {if $fieldName != 'status' && $fieldName != 'descr' && $fieldName != 'name_slug'} if ( {if $fValue}true{else}false{/if} ) { - console.log('{$fieldName}', $('input[name="{$fieldName}"]')); - console.log('{$fieldName}.val()', $('input[name="{$fieldName}"]').val()); + // console.log('{$fieldName}', $('input[name="{$fieldName}"]')); + // console.log('{$fieldName}.val()', $('input[name="{$fieldName}"]').val()); if ( !$('input[name="{$fieldName}"]').val() ) { formErrors.push('{$fieldName}'); } @@ -176,7 +176,7 @@ {else if $fieldName == 'descr'} if ( {if $fValue}true{else}false{/if} ) { descr = get_tinymce_content(); - console.log( 'descr', descr ); + // console.log( 'descr', descr ); if ( !descr ) { formErrors.push('{$fieldName}'); } @@ -186,7 +186,7 @@ {/foreach} var numErrors = formErrors.length; if ( numErrors > 0 ) { - console.log('formErrors: ', formErrors); + // console.log('formErrors: ', formErrors); var msg = "The following fields are required for this Event:\n"; for ( var i = 0; i < numErrors; i++ ) { msg += formErrors[i] + "\n"; @@ -1203,14 +1203,14 @@ {if $settings.selected_map_interface == 1} var nominatimAPI = "https://nominatim.openstreetmap.org/search/"; - + /* * Leaflet Map * API reference: https://leafletjs.com/reference-1.3.2.html */ function initMap(locID) { - console.log( 'locID: ', locID ); + // console.log( 'locID: ', locID ); // Set default - Need to make this configurable var startLat = $('#glmLat_' + locID).val(); @@ -1253,7 +1253,7 @@ $('#glm-estimate-location_' + locID).on('click', function() { var addrStreet = $('#address_' + locID).val(); - var addrCity = $('#city_' + locID + ' option:selected').text(); + var addrCity = $('#city_' + locID + ' option:selected').text().trim(); var addrState = $('#state_' + locID).val(); var addrCountry = $('#country_' + locID).val(); var addrZip = $('#zip_' + locID).val(); @@ -1267,27 +1267,27 @@ postalcode: addrZip }) .fail(function(data) { - alert('Sorry, we were unable to get a location from the above address.'); + alert('Sorry, we were unable to get a location from the above address.'); }) .done(function( data ) { if( !data[0] || !data[0].lat || !data[0].lon ) { alert('Sorry, we were unable to get a location from the above address.'); } else { - + // Assign the new position to the hidden fields for submission glmLat = Number(data[0].lat); glmLng = Number(data[0].lon); $('#glmLat_' + locID).val(glmLat.toFixed(6)); $('#glmLng_' + locID).val(glmLng.toFixed(6)); - + // Move map pointer to the proper location leafletMarker.setLatLng(new L.LatLng(glmLat, glmLng),{ draggable:'true' }); map[locID].panTo(new L.LatLng(glmLat, glmLng)); } - }); + }); }); @@ -1357,7 +1357,7 @@ } function glmGeocode(locID) { - + // Get all address parts var geoAddr1 = $('#address_' + locID ).val().trim(); var geoAddr2 = ''; // $('#addr2').val().trim(); @@ -1365,40 +1365,40 @@ var geoState = $('#state_' + locID).val(); var geoZIP = $('#zip_' + locID).val().trim(); var geoCountry = $('#country_' + locID).find('option:selected').text().trim(); - + // Assemble address string for var geoAddress = geoAddr1 + ', ' + geoAddr2 + ', ' + geoCity + ', ' + geoState + ' ' + geoZIP + ', ' + geoCountry; - + // Send to Google Geocoder geocoder[locID].geocode( { 'address': geoAddress }, function(results, status) { - + // If we have a geocode solution if (status == google.maps.GeocoderStatus.OK) { - + // Center the map and locate the marger to the new location map[locID].setCenter(results[0].geometry.location); marker[locID].setPosition( results[0].geometry.location ); - + // Assign the new position to the hidden fields for submission glmLat = results[0].geometry.location.lat(); glmLng = results[0].geometry.location.lng(); $('#glmLat_' + locID).val(glmLat.toFixed(6)); $('#glmLng_' + locID).val(glmLng.toFixed(6)); - + // Also display it to the user $('#mapPosition_' + locID).html('Lat ' + glmLat.toFixed(4) + ', Lon ' + glmLng.toFixed(4)); - + // Otherwise tell the user. } else { alert('Not able to estimate map position from the current address.'); } }); - - + + } {/if} - + /* * Misc support items */ -- 2.17.1