Using jQuery with Bing maps
Download jQuery 1.4.X or higher or use Googles or Microsofts CDN.
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js"></script> <script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.bmap.js"></script>
$('#map_canvas').gmap({'credentials': YOUR_BING_MAP_CREDENTIALS }).bind('init', function() {
$('#map_canvas').gmap('search', { 'address': 'New York, USA' }, function(result, status) {
if ( status === 'OK' ) {
var location = new Microsoft.Maps.Location(item.point.coordinates[0],item.point.coordinates[1]);
$('#map_canvas').gmap('addMarker', { 'location': location, 'bounds': true });
}
});
});
$('#map_canvas').gmap({'credentials': YOUR_BING_MAP_CREDENTIALS, 'callback': function(map) {
var self = this;
self.search( { 'address': 'New York, USA' }, function(result, status) {
if ( status === 'OK' ) {
var location = new Microsoft.Maps.Location(item.point.coordinates[0],item.point.coordinates[1]);
self.addMarker( { 'location': location, 'bounds': true });
}
});
}});