From: Chuck Scott Date: Thu, 29 Nov 2018 20:27:17 +0000 (-0500) Subject: Added automatic mapping for the location address when zip is entered if still have... X-Git-Tag: v1.7.9^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=469a341a61cb3681749feff76c3cb36b877a8c42;p=WP-Plugins%2Fglm-member-db-events.git Added automatic mapping for the location address when zip is entered if still have default lat/lon. --- diff --git a/index.php b/index.php old mode 100644 new mode 100755 index 86fc3b6..e3eefb9 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Associate - Events Add-On * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 1.7.8 + * Version: 1.7.9 * Author: Chuck Scott * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -19,7 +19,7 @@ * @package glmMembersDatabaseEventsAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.7.8 + * @version 1.7.9 */ // Check that we're being called by WordPress. @@ -43,7 +43,7 @@ if (!defined('ABSPATH')) { * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.7.8'); +define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.7.9'); define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.10'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/readme.txt b/readme.txt old mode 100644 new mode 100755 index 3538727..9d65f2f --- a/readme.txt +++ b/readme.txt @@ -25,6 +25,12 @@ e.g. 1. Activate the plugin through the 'Plugins' menu in WordPress == Changelog == += 1.7.9 = +* When editing a location for an event and the map is still showing the default location, + it will try to map the address and notify the user that it's doing this. +* When looking up addresses for the map it will no longer incorrectly match a roadway as + the target object. + = 1.6.89 = * Fixed date range displayed for an event when included in an event list. diff --git a/views/admin/events/edit.html b/views/admin/events/edit.html index 4e1b3e6..3f2770b 100755 --- a/views/admin/events/edit.html +++ b/views/admin/events/edit.html @@ -1257,28 +1257,66 @@ // When estimate location button is clicked, geocode using address var addressMapFail = 'Sorry, we were unable to get a map position from the address provided.'; + + // Do address lookup if "Map Location" button clicked $('#glm-estimate-location_' + locID).on('click', function() { + lookupAddress(locID); + }); + + // Do address lookup if ZIP is changed and the lat/lon is still the default + $('.zipcode-input').on('change', function() { + locID = $(this).attr('data-id'); + var addrZip = $('#zip_' + locID).val(); + var lat = $('#glmLat_' + locID).val(); + var lng = $('#glmLng_' + locID).val(); + if ({$newLocation.fieldData.lat} == lat && {$newLocation.fieldData.lon} == lng ) { + alert("The map location for this address has not yet been set.\n\nWe'll try to find it, but if the map location isn't correct,\nyou can drag to pointer to the correct location."); + lookupAddress(locID); + } + }); + // Do address lookup using Nominatim + function lookupAddress(locID) { var addrStreet = $('#address_' + locID).val(); var addrCity = $('#city_' + locID + ' option:selected').text().trim(); var addrState = $('#state_' + locID).val(); var addrCountry = $('#country_' + locID).val(); var addrZip = $('#zip_' + locID).val(); +console.log({ + format: 'json', + street: addrStreet, + city: addrCity, + state: addrState, + country: addrCountry, + postalcode: addrZip +}); + var location = $.getJSON( nominatimAPI, { format: 'json', street: addrStreet, city: addrCity, state: addrState, country: addrCountry, - postalcode: addrZip + postalcode: addrZip, + result: 1 }) .fail(function(data) { alert('Sorry, we had a communications failure. 2'); }) .done(function( data ) { +console.log(data); + if( !data[0] || !data[0].lat || !data[0].lon || data[0].type == 'unclassified') { + +console.log({ + format: 'json', + street: addrStreet, + // city: addrCity, + state: addrState, + country: addrCountry, + postalcode: addrZip +}); - if( !data[0] || !data[0].lat || !data[0].lon ) { // Not found, try again without city name // Nominatim doesn't always find with the US ZIP preferred city name var location = $.getJSON( nominatimAPI, { @@ -1287,7 +1325,8 @@ // city: addrCity, state: addrState, country: addrCountry, - postalcode: addrZip + postalcode: addrZip, + result: 1 }) .fail(function(data) { alert('Sorry, we had a communications failure. 2'); @@ -1307,7 +1346,7 @@ }); - }); + } // Assign a position found by the Nominatim search above function assignNewPosition(data) { diff --git a/views/admin/events/editLocation.html b/views/admin/events/editLocation.html index 954c5ce..1df04bd 100755 --- a/views/admin/events/editLocation.html +++ b/views/admin/events/editLocation.html @@ -97,7 +97,7 @@ Address: - + @@ -106,7 +106,7 @@
Add a new City
- {foreach from=$loc.city.list item=v} {foreach from=$loc.state.list item=v} {foreach from=$newLocation.fieldData.city.list item=v} @@ -268,7 +268,7 @@ State: - {foreach from=$newLocation.fieldData.state.list item=v}