Unlock

Questions?

Project Blog

|

Contact Us envelope image
Home > Unlock Places > Code Samples

Code Samples

JavaScript

Simple search using a Javascript callback

The example below is an entire webpage, which requests a list of 10 features (by name) using a Javascript function. When the JSON is returned, it is wrapped in a callback function which is added to the page and executed. The callback displays the list of features and creates hyperlinks to each feature's footprint.

Demo

Feature name:

Source Code
<html>
<head>

</head>
 
<body>
    

Feature name:

</body> </html>

Auto-suggest search using jQuery

Using jQuery UI Autocomplete the code below makes a request to Unlock's search API and suggests results. It can be embedded on to any web page, giving your application access to the Unlock gazetteer.

Demo

Feature name:

Source Code
<html>
<head>
    
    
    
    
</head>
<body>
    

Feature name:

</body> </html>

Python

A Python client package is available to easily access the Unlock API.

Source Code
easy_install unlock

from unlock import Places

p = Places()
xml = p.nameSearch('Corstorphine Hill')
print xml

returns



  1
  
      4576692
      2652310
      Corstorphine Hill
      -3.27232718467712
      55.95105005
      -3.27232718467712
      55.95105005
      Hill
      United Kingdom
      GB
      West Lothian
      
      
      GeoNames
      GeoNames
      unknown
      -3.27232718467712,55.95105005
      
  


Download the Unlock client package from PyPi.