* 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
* @package glmMembersDatabaseEventsAddOn
* @author Chuck Scott <cscott@gaslightmedia.com>
* @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.7.8
+ * @version 1.7.9
*/
// Check that we're being called by WordPress.
* 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.
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.
// 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, {
// city: addrCity,
state: addrState,
country: addrCountry,
- postalcode: addrZip
+ postalcode: addrZip,
+ result: 1
})
.fail(function(data) {
alert('Sorry, we had a communications failure. 2');
});
- });
+ }
// Assign a position found by the Nominatim search above
function assignNewPosition(data) {
<tr>
<th>Address:</th>
<td>
- <input id="address_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium location-address">
+ <input id="address_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium">
</td>
</tr>
<tr>
<!-- Add new city dialog -->
<div data-id="{$loc.id}" class="button button-secondary glm-right new-city-button">Add a new City</div>
<!-- City Selection -->
- <select id="city_{$loc.id}" data-id="{$loc.id}" class="city-picklist location-address" name="Loc{$loc.id}_city">
+ <select id="city_{$loc.id}" data-id="{$loc.id}" class="city-picklist" name="Loc{$loc.id}_city">
<option value="0"></option>
{foreach from=$loc.city.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
<tr>
<th>State:</th>
<td>
- <select id="state_{$loc.id}" data-id="{$loc.id}" class="location-address" name="Loc{$loc.id}_state">
+ <select id="state_{$loc.id}" data-id="{$loc.id}" class="" name="Loc{$loc.id}_state">
<option value=""></option>
{foreach from=$loc.state.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
<tr>
<th>ZIP / Postal Code:</th>
<td>
- <input id="zip_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium location-address">
+ <input id="zip_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium zipcode-input">
</td>
</tr>
<tr>
<th>Country:</th>
<td>
- <select id="country_{$loc.id}" data-id="{$loc.id}" class="location-address" name="Loc{$loc.id}_country">
+ <select id="country_{$loc.id}" data-id="{$loc.id}" name="Loc{$loc.id}_country">
{foreach from=$loc.country.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
{$v.name} {$v.value}
<tr>
<th>Address:</th>
<td>
- <input id="address_{ newLocID }" data-id="{ newLocID }" type="text" name="{ newLocID }_address" value="{$newLocation.fieldData.address}" class="glm-form-text-input-medium location-address">
+ <input id="address_{ newLocID }" data-id="{ newLocID }" type="text" name="{ newLocID }_address" value="{$newLocation.fieldData.address}" class="glm-form-text-input-medium">
</td>
</tr>
<tr>
<!-- Add new city dialog -->
<div data-id="{ newLocID }" class="button button-secondary glm-right new-city-button">Add a new City</div>
<!-- City Selection -->
- <select id="city_{ newLocID }" data-id="{ newLocID }" class="city-picklist location-address" name="{ newLocID }_city">
+ <select id="city_{ newLocID }" data-id="{ newLocID }" class="city-picklist" name="{ newLocID }_city">
<option value="0"></option>
{foreach from=$newLocation.fieldData.city.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
<tr>
<th>State:</th>
<td>
- <select id="state_{ newLocID }" data-id="{ newLocID }" class="location-address" name="{ newLocID }_state">
+ <select id="state_{ newLocID }" data-id="{ newLocID }" name="{ newLocID }_state">
{foreach from=$newLocation.fieldData.state.list item=v}
<option value="{$v.value}"{if $v.value == $eventDefaultState} selected="selected"{/if}>
{$v.name} {if $eventDefaultState == $v.value} (default) {/if}
<tr>
<th>ZIP / Postal Code:</th>
<td>
- <input id="zip_{ newLocID }" data-id="{ newLocID }" type="text" name="{ newLocID }_zip" value="{$newLocation.fieldData.zip}" class="glm-form-text-input-medium location-address">
+ <input id="zip_{ newLocID }" data-id="{ newLocID }" type="text" name="{ newLocID }_zip" value="{$newLocation.fieldData.zip}" class="glm-form-text-input-medium zipcode-input">
</td>
</tr>
<tr>
<th>Country:</th>
<td>
- <select id="country_{ newLocID }" data-id="{ newLocID }" class="location-address" name="{ newLocID }_country">
+ <select id="country_{ newLocID }" data-id="{ newLocID }" name="{ newLocID }_country">
{foreach from=$newLocation.fieldData.country.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
{$v.name} {$v.value}