2013-10-19 30 views

回答

0

您可以通過改變PolylinezIndex的財產,像所有MapObjects的,則折線Object得出這是zIndex的定義哪裏做到這一點。

如果你有一個這樣的折線:像這樣

var points = [ 
new nokia.maps.geo.Coordinate(50.2, 8.57), 
     new nokia.maps.geo.Coordinate(50.1299, 8.5680), 
     new nokia.maps.geo.Coordinate(50.0969, 8.4829), 
     new nokia.maps.geo.Coordinate(50.0819, 8.4856), 
     new nokia.maps.geo.Coordinate(50.0555, 8.4479), 
     new nokia.maps.geo.Coordinate(50.02, 8.43) 
    ]; 

// Purple polyline 
poly = new nokia.maps.map.Polyline(
    points, 
    { 
     pen: { 
      strokeColor: "#22CA", 
      lineWidth: 5 
     } 
    } 
); 

而且任何geoshape(如多邊形):

gon = new nokia.maps.map.Polygon(
    [ 
     new nokia.maps.geo.Coordinate(50.2001, 8.6381), 
     new nokia.maps.geo.Coordinate(50.2190, 8.5474), 
     new nokia.maps.geo.Coordinate(50.2001, 8.5337), 
     new nokia.maps.geo.Coordinate(50.1799, 8.4774), 
     new nokia.maps.geo.Coordinate(50.1693, 8.4664), 
     new nokia.maps.geo.Coordinate(50.1522, 8.4657), 
     new nokia.maps.geo.Coordinate(50.1205, 8.5310), 
     new nokia.maps.geo.Coordinate(50.1363, 8.5879), 
     new nokia.maps.geo.Coordinate(50.1882, 8.6168) 

    ], 
    { 
     pen: { strokeColor: "#000", lineWidth: 1 }, 
     brush: { color: "#C22A" } 
    } 
); 

,然後將其放置在地圖上的對象第一會在後面。默認情況下,兩個對象的zIndex爲零。如果增加zIndex的如圖所示:

poly.set("zIndex", 1) 

然後,它會在所有對象的頂部移動使用默認zIndex的

+0

謝謝,這是非常有幫助=) – emilio

+0

看來,Z-索引是相對於容器(也有z-索引)。所以如果你有不同容器中的對象,它可能會變得棘手。我最終改變了容器的z-索引。 –

相關問題