Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why BingMap heatMap doesn't show the correct location?

I was trying to show a location using heatMap module in bingMap. When I try to use some location heatMap show me diffrect location to that long and lat,

HeatMap

I just change the code like following way
`

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Microsoft.Maps.loadModule('Microsoft.Maps.HeatMap', function () {
    var mapDiv = map.getRootElement();
    
    var locations = [];
    
    locations.push(map.tryPixelToLocation(new Microsoft.Maps.Point(28.150900,-81.468440), Microsoft.Maps.PixelReference.control));
    
    
    var heatMap = new Microsoft.Maps.HeatMapLayer(locations);
    map.layers.insert(heatMap);
});

This location is for 410 Marlberry Leaf Ave, Kissimmee, FL 34758, USA but heatMap show me a location in ALESKA

>Solution :

The issue is that you are taking the lat/long coordinates and treating it as a pixel point and converting it into a location. This results in a completely different coordinate. Remove the call to map.tryPixelToLocation( and use the Location class instead of the Point class.

Here is a modified version of your code:

Microsoft.Maps.loadModule('Microsoft.Maps.HeatMap', function () {
    var mapDiv = map.getRootElement();
    
    var locations = [];
    
    locations.push(new Microsoft.Maps.Location(28.150900,-81.468440));
    
    
    var heatMap = new Microsoft.Maps.HeatMapLayer(locations);
    map.layers.insert(heatMap);
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading