Forum Discussion

JamesDavis's avatar
JamesDavis
Cloud Apps
07-30-2024
Solved

Can you plot a single point on a scatter map to indicate my office location vs my data plots

Hi everyone, I am wondering if anyone has any widget script that allows you to plot a single point on a scatter map widget that allows you to easily see how your usual plot points are located comp...
  • Vadim_Pidgornyi's avatar
    Vadim_Pidgornyi
    08-15-2024

    Hello, 

    Based on the following: 

    https://leafletjs.com/examples/custom-icons/

    You can use any of the publicly available image URLs, here is an example. 

    const officeCoordinates = {
    latitude: 65.5859012851966,
    longitude: -105.75059585651
    };
    
    var greenIcon = L.icon({
        iconUrl: 'https://leafletjs.com/examples/custom-icons/leaf-green.png',
        shadowUrl: 'https://leafletjs.com/examples/custom-icons/leaf-shadow.png',
    
        iconSize:     [38, 95], // size of the icon
        shadowSize:   [50, 64], // size of the shadow
        iconAnchor:   [22, 94], // point of the icon which will correspond to marker's location
        shadowAnchor: [4, 62],  // the same for the shadow
        popupAnchor:  [-3, -76] // point from which the popup should open relative to the iconAnchor
    });
    
    widget.on('beforeviewloaded', (scope, args) => {
    const { latitude, longitude } = officeCoordinates;
    if (!L.Icon.Default.imagePath) L.Icon.Default.imagePath = '/plugins/images/';
    L.marker([latitude, longitude]).addTo(args.options.map);
    L.marker([51.5, -0.09], {icon: greenIcon}).addTo(args.options.map);
    })