none
Heatmap and event click RRS feed

  • Question

  • Hi all, 

    I need to show some information about some specific heatmap area. I've been doing a little research about Heatmaps and pushpin, however, I couldn't implement any event on the heatmap area.

    Does anyone know if it is possible to add events to the locations over the heatmap?

    Thanks in advance.

    Regards.

    Gustavo 

    Friday, May 3, 2019 6:55 PM

All replies

  • Hi Gustavo,

    Your heatmap should be in a layer like: https://www.bing.com/api/maps/sdk/mapcontrol/isdk/defaultheatmap

    and then you can add pushpins like https://www.bing.com/api/maps/sdk/mapcontrol/isdk/adddefaultpushpin

    I put the two together and they worked for me like:

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        /* No need to set credentials if already passed in URL */
        center: new Microsoft.Maps.Location(39.393486, -98.100769),
        zoom: 3 });
    	
    Microsoft.Maps.loadModule('Microsoft.Maps.HeatMap', function () {
        // Creating sample Pushpin data within map view
        var mapDiv = map.getRootElement();
        /* locations can be the mix of Location and WeightedLocation */
        var locations = [];
    	var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(), null);
    map.entities.push(pushpin);
        for (var i = 0; i < 500; i++) {
            var weightedLocation = new Microsoft.Maps.WeightedLocation(map.tryPixelToLocation(new Microsoft.Maps.Point(mapDiv.clientWidth * Math.random(), mapDiv.clientHeight * Math.random()), Microsoft.Maps.PixelReference.control), Math.random());
            locations.push(weightedLocation);
        }
        for (i = 0; i < 500; i++) {
            locations.push(map.tryPixelToLocation(new Microsoft.Maps.Point(mapDiv.clientWidth * Math.random(), mapDiv.clientHeight * Math.random()), Microsoft.Maps.PixelReference.control));
        }
        var heatMap = new Microsoft.Maps.HeatMapLayer(locations);
        map.layers.insert(heatMap);
    });
    

    Sincerely,

    IoTGirl

    Friday, May 3, 2019 7:31 PM
    Owner