Resetting Cursor in Bing Maps – Support IE

August 10, 2015

I was having trouble resetting my Bing Maps implementation cursor back from a cross-hair (used when plotting a pin) to the default grab cursor.

I found that a slightly modified cursor url did the trick:

Old – _map.getRootElement().style.cursor =’url(https://ecn.dev.virtualearth.net/mapcontrol/v7.0/7.0.20150720111303.14/cursors/grabbing.cur) 10 9, move’;

New – _map.getRootElement().style.cursor =’url(https://ecn.dev.virtualearth.net/mapcontrol/v7.0/7.0.20150720111303.14/cursors/grab.cur), move’;


Formatting Javascript Date with Month Name

February 16, 2015

Oh the limitations of javascript… So I needed a way to produce a date/time string that would match the way I format my date/time strings in C# (MMMM dd, yyyy hh:mm:ss tt). As most know, javascript isn’t very nice when it comes to working with dates/times. My project had the added benefit of some special requirements. jQuery could be used, but no plug-ins are allowed.

After doing plenty of searching and posing a question on StackOverflow, I came up with this function. I sure wish the function could be shorter…


function getFormattedDateTime(dateTimeToFormat) {
dateTimeToFormat = new Date(dateTimeToFormat);

var zeroPad = function (val) {
return (val <= 9 ? '0' + val : '' + val);
};

var month = dateTimeToFormat.toLocaleString('en-us', {month: "long"});
var day = dateTimeToFormat.getDate();
var year = dateTimeToFormat.getFullYear();

var hour = ((dateTimeToFormat.getHours() + 11) % 12 + 1);
var minutes = dateTimeToFormat.getMinutes();
var seconds = dateTimeToFormat.getSeconds();
var suffix = (hour <= 12) ? 'AM' : 'PM';

return month + ' ' + zeroPad(day) + ', ' + year + ' ' + zeroPad(hour) + ':' + zeroPad(minutes) + ':' + zeroPad(seconds) + ' ' + suffix;
}

You can play with this function in action on JSFiddle