Change z-index of marker in openlayers -


i've layer multiple markers rather big icons, overlap. via list on side of map users can select marker , map pan (and zoom) it. still behind other makers. how individual makers z-index , set it? useful highest used z-index , add one. (another solution add total number of markers z-index)

the markers (or features) in mylib.features array. console doesn't show z-index type functions.

i can't find appropriate example or api function this.

edit:

i found example: http://dev.openlayers.org/examples/ordering.html don't understand it. somehow created feature takes next z-index given layer via somekind of symbolizer. have no idea how work static sort dynamic one.

try this:

first of all, make sure using openlayers.layer.vector layer, not openlayers.layer.markers layer. apparently markers layer old news , new development done in vector layer. has more features. (i wasted pile of time markers layer myself).

then, each of markers needs openlayers.feature.vector object. constructor takes 3 arguments, third of called style. style set image attributes, background shadow, mouse-over text, , z-index, has property name "graphiczindex". think that's you're looking for.

http://dev.openlayers.org/releases/openlayers-2.12/doc/apidocs/files/openlayers/feature/vector-js.html#openlayers.feature.vector.openlayers.feature.vector.style

add "markers" (which vector's) vector layer addfeatures function. , ignore "options" argument.

http://dev.openlayers.org/releases/openlayers-2.12/doc/apidocs/files/openlayers/layer/vector-js.html#openlayers.layer.vector.addfeatures

i found example page too, , found confusing too. setting markers' styles in vector layer's constructor (as default values used if marker style omitted) instead of marker's constructor. think makes more sense set marker style in marker constructor.

to change style in real-time, take 1 of openlayers.feature.vector markers, called "marker" , this. , let's call vector layer "layer".

marker.style.graphiczindex = 13; layer.redraw(); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -