Don't suppose anyone here has tried Bing maps API in jscript but worth a try.
Trying to set up a thing where local council can click on a map and see details & picture of any current footpath problems. All working fine except that the info boxes can go off top of screen, so need to scroll map down, ie centre on a more Northerly latitude, but can't get it to adjust properly.
Problem is , don't think it's my cockup, the methods just don't seem to work - see this simple bit of test code.
map.setView({center: new Microsoft.Maps.Location(lat[n],lon[n])});
alert("x");
var x = 0.5 * map.getWidth();
var y = 0.5 * map.getHeight();
var point = new Microsoft.Maps.Point(x, y);
var location = map.tryPixelToLocation(point);
map.setView({center: new Microsoft.Maps.Location(location.latitude,location .longitude)});
The map centres on the supplied lat/long in line 1. If I then get the centre of the map in pixels and convert that back to lat/long I should surely be at the same location, but it's way off, 500m or more.
Any ideas? Cheers.
Trying to set up a thing where local council can click on a map and see details & picture of any current footpath problems. All working fine except that the info boxes can go off top of screen, so need to scroll map down, ie centre on a more Northerly latitude, but can't get it to adjust properly.
Problem is , don't think it's my cockup, the methods just don't seem to work - see this simple bit of test code.
map.setView({center: new Microsoft.Maps.Location(lat[n],lon[n])});
alert("x");
var x = 0.5 * map.getWidth();
var y = 0.5 * map.getHeight();
var point = new Microsoft.Maps.Point(x, y);
var location = map.tryPixelToLocation(point);
map.setView({center: new Microsoft.Maps.Location(location.latitude,location .longitude)});
The map centres on the supplied lat/long in line 1. If I then get the centre of the map in pixels and convert that back to lat/long I should surely be at the same location, but it's way off, 500m or more.
Any ideas? Cheers.
Comment