Monday, 14 September 2015

Google autocomplete ambiguous address - same street name in different cities or suburbs

Ambiguous address issue

When entering the address of '29 Karaka Street' in the google autocomplete input, the first hint should be '29 Karaka Street, Auckland, New Zealand', but since there are quite a few streets in NZ having the same street name of 'Karaka', it may cause some issue/misunderstanding of using the location. In addition, when inputting this address in google maps, goold maps will note that 'we couldn't find this address'.

How to solve the issue

Use google maps geocoding API to check whether the address is unique as below:
https://maps.googleapis.com/maps/api/geocode/json?address=29%20karaka%20street&components=country:NZ&key=YOUR_KEY
If there are multiple 'address_components' in the result, it means the address is not unique and we need to display some notes for user such as 'add a suburb or a postcode to make the address more clear'


Wednesday, 2 September 2015

How to fix Theme Developer module not showing caused by the conflict with JQuery

Symptom and the error message from JS console

The theme developer pop-up doesn't show up on the website.
When open Chrome Console, there is an error message saying that 'Uncaught Error: Syntax error, unrecognized expression:
'


Solution

Open the file with path of 'sites/all/modules/devel_themer/devel_themer.js'
Search the following snippet which is the source of the issue:
$(Drupal.settings.thmr_popup)
      .appendTo($('body'));
Use the snippet below to replace the above one:
$($.parseHTML(Drupal.settings.thmr_popup))
       .appendTo($('body'));
Note: The reason of this issue is that JQuery doesn't support putting html string in to the dollar function anymore.