Skip to content

navkumar258/thingworx-leaflet-widget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Thingworx Leaflet Widget

A custom Thingworx widget (v7.4.8+) that integrates Leaflet - an open-source JavaScript library for mobile-friendly interactive maps - into your Thingworx applications.

πŸš€ Features

  • GeoJSON Support: Import and display GeoJSON data for complex geographical visualizations
  • Custom Background Images: Use your own map images as background layers
  • Circular Geofences: Create configurable circular zones with customizable input data
  • Debug Mode: Built-in debugging capabilities for development and troubleshooting
  • Mobile-Friendly: Responsive design that works across all devices
  • Interactive Maps: Full Leaflet.js functionality with zoom, pan, and click interactions

πŸ“‹ Prerequisites

  • Thingworx Platform v7.4.8 or higher
  • Modern web browser with JavaScript enabled
  • Basic familiarity with Thingworx Composer

��️ Installation

Step 1: Download the Extension

Download Leaflet_v1.0.0.zip from the releases section of this repository.

Step 2: Import into Thingworx Composer

  1. Open Thingworx Composer
  2. Navigate to Import/Export β†’ Import
  3. Select the downloaded Leaflet_v1.0.0.zip file
  4. Follow the import wizard to complete the installation
  5. Restart your Thingworx server if prompted

🎯 Usage

Adding the Widget to Your Mashup

  1. Open Mashup Builder: Create a new mashup or open an existing one
  2. Locate the Widget: In the widgets tab, search for "Leaflet" or browse the widget library
  3. Add to Mashup: Drag and drop the Leaflet widget onto your mashup canvas
  4. Configure Properties: Bind your data and image properties as needed
  5. Test and Deploy: Preview your mashup and deploy when ready

Basic Configuration

// Example widget configuration
{
  "geoJsonData": "your-geojson-data",
  "backgroundImage": "path/to/your/map-image.png",
  "geofences": [
    {
      "center": [40.7128, -74.0060],
      "radius": 1000,
      "color": "#ff0000",
      "opacity": 0.5
    }
  ],
  "debugMode": false
}

βš™οΈ Configuration Properties

Property Type Description Default
geoJsonData String/JSON GeoJSON data to display on the map null
backgroundImage String URL or path to custom background image null
geofences Array Array of circular geofence objects []
debugMode Boolean Enable/disable debug mode false
mapCenter Array Initial map center [lat, lng] [0, 0]
zoomLevel Number Initial zoom level (1-18) 10

Geofence Configuration

Each geofence object supports the following properties:

{
  "center": [latitude, longitude],  // Required: Center coordinates
  "radius": 1000,                   // Required: Radius in meters
  "color": "#ff0000",              // Optional: Fill color (hex)
  "opacity": 0.5,                  // Optional: Fill opacity (0-1)
  "strokeColor": "#000000",        // Optional: Border color
  "strokeWidth": 2,                // Optional: Border width
  "label": "Zone 1"                // Optional: Display label
}

πŸ”§ Advanced Usage

GeoJSON Data Format

The widget accepts standard GeoJSON format:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-74.0060, 40.7128]
      },
      "properties": {
        "name": "New York",
        "description": "The Big Apple"
      }
    }
  ]
}

Custom Background Images

To use a custom map image as background:

  1. Upload your image to Thingworx file repository
  2. Set the backgroundImage property to the file path
  3. Ensure the image has proper geographical coordinates or bounds

Debug Mode

Enable debug mode to:

  • View console logs for troubleshooting
  • Display additional map information
  • Show coordinate information on hover
  • Validate data formats

πŸ› Troubleshooting

Common Issues

Widget not appearing in library:

  • Ensure the extension was imported successfully
  • Check Thingworx server logs for import errors
  • Restart the Thingworx server

Map not loading:

  • Verify internet connection (for default map tiles)
  • Check browser console for JavaScript errors
  • Ensure Leaflet library is loading properly

GeoJSON not displaying:

  • Validate your GeoJSON format
  • Check coordinate system (widget expects WGS84)
  • Enable debug mode to see detailed error messages

Geofences not showing:

  • Verify coordinate format is [lat, lng]
  • Check radius values are positive numbers
  • Ensure color values are valid hex codes

πŸ“± Browser Compatibility

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+
  • Internet Explorer 11 (with polyfills)

🀝 Contributing

We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

πŸ†˜ Support

οΏ½οΏ½ Acknowledgments

πŸ“ˆ Version History

v1.0.0

  • Initial release
  • GeoJSON support
  • Custom background images
  • Circular geofences
  • Debug mode
  • Mobile-friendly design

⭐ If this widget helps you, please consider giving it a star!

For more information about Thingworx development, visit the official documentation.

About

Thingworx v7.4.8+ leaflet widget for using interactive maps in your application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors