I just started working with OpenLayers because I want to include a map on my JSF page (.xhtml files). I want to use the same feature that is demonstrated in this example: http://openlayers.org/dev/examples/styles-context.html

I played with the code a little bit in the html example files that come with the .zip download.

When I copied the code into my JSF .xhtml page, the map appears but the markers are not displayed. Here is the example code:

<script type="text/javascript">
var map;
function init(){
 map = new OpenLayers.Map('map', {maxResolution:'auto'});
var wms = new OpenLayers.Layer.WMS.InlineXhtml( "OpenLayers WMS",
 "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic', format: 'image/svg+xml'} );

// create 50 random features in the northern hemisphere
 // give them a "type" attribute that will be used to style
// them by size
var features = new Array(50);
            for (var i=0; i<features.length; i++) {
 features[i] = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(
                        (360 * Math.random()) - 180, 90 * Math.random()
), {
 type: 5 + parseInt(5 * Math.random())

 // allow testing of specific renderers via "?renderer=Canvas", etc
 var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
 renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;

            // create the layer styleMap with a simple symbolizer template
yer1 = new OpenLayers.Layer.Vector('Points', {
styleMap: new OpenLayers.StyleMap({
pointRadius: "${type}", // based on feature.attributes.type
 fillColor: "#000000"
 renderers: renderer


I added:


and changed the markers from 50 random to 2 markers of the coordinates of London and Berlin. And the map was centered exactly to show them, but the markers are still not displayed. But that proves that the markers are read and loaded to the map correctly, just not displayed. If I do the same back in the example .html page the map is again centered properly and the markers are displayed.

Is it the problem of xhtml? How to fix this?

asked 10 May '12, 14:57

srd_pl's gravatar image

accept rate: 0%

closed 10 May '12, 15:19

Frederik%20Ramm's gravatar image

Frederik Ramm ♦

The question has been closed for the following reason "This is not an OpenLayers support forum. Your Question is not OpenStreetMap related. Please see http://openlayers.org/ for OpenLayers mailing lists and support." by Frederik Ramm 10 May '12, 15:19

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 10 May '12, 14:57

question was seen: 2,177 times

last updated: 10 May '12, 15:19

powered by OSQA