0

我一直在尝试这样的事情: laststmarker is a nokia.maps.map.StandardMarker ncolor is a string= #0000FF

    laststmarker.brush=ncolor;
    laststmarker.brush="{color:'"+ncolor+"'}";
    laststmarker.brush={color:ncolor};

和其他东西,我如何在不删除的情况下更改颜色并将其再次添加到地图中?

4

1 回答 1

0

这里要注意的重要一点是画笔不可变的——这意味着你不能直接更新参数——你需要使用设置器,例如 marker.set("brush" , { color :"#FF0000"});——这通常是map.update(-1,0);为了刷新地图。

下面的示例在鼠标指针悬停在标记上时突出显示该标记。您需要使用自己的应用程序 ID 和令牌才能使其正常工作。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9" />


<base href="http://www.wrc.com/" />
<title>Highlighing a marker</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

<script language="javascript"  src="http://api.maps.nokia.com/2.2.4/jsl.js" type="text/javascript" charset="utf-8"></script>

</head>
<body>
<p> Place your pointer over the marker to highlight it.</p>
<div id="gmapcanvas"  style="width:600px; height:600px;" >&nbsp;</div><br/><br/>    


<script type="text/javascript">
// <![CDATA[    

/////////////////////////////////////////////////////////////////////////////////////
// Don't forget to set your API credentials
//
// Replace with your appId and token which you can obtain when you 
// register on http://api.developer.nokia.com/ 
//
            nokia.Settings.set( "appId", "YOUR APP ID GOES HERE"); 
            nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");

/////////////////////////////////////////////////////////////////////////////////////   

 map = new nokia.maps.map.Display(document.getElementById('gmapcanvas'), {
     'components': [ 
        // Behavior collection
        new nokia.maps.map.component.Behavior() ],
    'zoomLevel': 5, // Zoom level for the map
    'center': [41.0125,28.975833] // Center coordinates
});
// Remove zoom.MouseWheel behavior for better page scrolling experience
map.removeComponent(map.getComponentById("zoom.MouseWheel"));



var normalMarker  =  new nokia.maps.map.StandardMarker(new nokia.maps.geo.Coordinate(41.0125,28.975833), {brush: {color: "#FF0000"}});
normalMarker.addListener("mouseover" ,  function(evt) { 
        normalMarker.set("brush" , { color :"#0000FF"});
        map.update(-1,0);

 }, false);

normalMarker.addListener("mouseout" ,  function(evt) { 
        normalMarker.set("brush" , { color :"#FF0000"});
        map.update(-1,0);

 }, false);     

map.objects.add(normalMarker);

// ]]>
</script>



</body>
</html>
于 2013-03-25T12:29:38.797 回答