Canadian Address Lookup Widget System

This document describes the widget generation and embedding system for the Canadian Census Data application.

Overview

The widget system allows users to create customizable address lookup widgets that can be embedded on any website. These widgets provide a user-friendly interface for searching Canadian addresses using the Census Data API.

Features

File Structure

├── widget_generator.php    # Widget creation interface
├── widget.php             # Widget endpoint (serves the actual widget)
├── widget_manager.php     # Widget management interface
├── widget_demo.html       # Demo page showing widget usage
└── WIDGET_README.md       # Markdown documentation

Usage Guide

  1. Creating a Widget: Go to the Widget Generator, configure your settings, and click "Generate Widget".
  2. Embedding a Widget: Copy the generated embed code and paste it into your HTML:
<iframe src="http://your-domain.com/widget.php?id=YOUR_WIDGET_ID" 
        width="400" 
        height="300" 
        frameborder="0" 
        style="border: none; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);">
</iframe>
  1. Handling Address Selection: Listen for address selection events from the widget:
window.addEventListener('message', function(event) {
    if (event.data.type === 'address_selected') {
        console.log('Address selected:', event.data.address);
        console.log('Location:', event.data.location);
        // Handle the selected address in your application
    }
});

API Integration

Supported search parameters: street, city, postcode, pruid, limit

Themes

Security Considerations

Customization Options

Browser Support

Troubleshooting

Enable debug mode by adding ?debug=1 to the widget URL.

Performance Optimization

Future Enhancements

Support

  1. Check the API documentation
  2. Review the demo page
  3. Test with the widget generator
  4. Check browser console for errors

License

This widget system is part of the Canadian Census Data application and follows the same licensing terms.