Can't set mouse cursor to crosshair
i'm trying set mouse cursor crosshair (from default hand) , it's not working:
document.getelementbyid(
"map").style.cursor = "crosshair";steve kahler
this question solved on forums:
and here sample code:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript" charset="utf-8" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&onscriptload=getmap"> </script> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.1.js"></script> <script type="text/javascript"> var map = null; var cursorstyle = null; function getmap() { // initialize map map = new microsoft.maps.map($('#map').get(0), { credentials: "yourkey", center: new microsoft.maps.location(47.5, 2.75), zoom: 4, maptypeid: microsoft.maps.maptypeid.road }); var pin = new microsoft.maps.pushpin(new microsoft.maps.location(47.5, 2.75)); map.entities.push(pin); microsoft.maps.events.addhandler(pin, 'mouseover', changecursor); microsoft.maps.events.addhandler(pin, 'mouseout', revertcursor); } function changecursor(e) { $('.microsoftmap').css({'cursor':'pointer'}); } function revertcursor(e) { $('.microsoftmap').css({'cursor':'url("http://ecn.dev.virtualearth.net/mapcontrol/v7.0/cursors/grab.cur"), move'}); } </script> </head> <body onload="getmap();"> <div id="map" style="position: relative; width: 800px; height: 600px;"> </div> </body> </html>
if don't want scenario, can use first solution brought chris make sure apply style on correct element , consider fact there build-in styles , might need override them using !important note on style.
in case, try root element , apply style returned element.
microsoft.maps.events.addhandler(map, "mousemove", function (e) { // html dom element represents map var mapelem = map.getrootelement(); if (e.targettype === "map") { // mouse on map mapelem.style.cursor = "crosshair"; } else { // mouse on pushpin, polyline, polygon mapelem.style.cursor = "pointer"; } });
mvp - bing maps - blog (fr): http://blogs.developpeur.org/nicoboo/ twitter: http://twitter.com/nicolasboonaert/
Bing Maps > Bing Maps Web Controls
Comments
Post a Comment