[OpenLayers-Users] OL 2.12: OpenLayers.Layer.Vector only shows up at zoomed out resolutions

Jeff Heard jefferson.r.heard at gmail.com
Wed Aug 1 05:33:54 PDT 2012


I'm running the latest version of OpenLayers in conjunction with JQuery
1.7.2 and JQueryMobile 1.1.1, and my problem is this: I have a vector layer
that will not show up except under extremely zoomed out conditions.  I have
another vector layer defined the same way that shows up fine.  I can zoom
out and all the features are exactly where they're supposed to be, but I
get nothing from the Participants layer.  Anyone got a clue?

So I have a vector layer, which I merely instantiated like this:

var participantsLayer = new OpenLayers.Layer.Vector("Participants");

I then added some features to it:

             iter(data, function(participant) {
                    participants[participant.user.resource_uri] =
participant;
                    var f = participantsLayer.getFeatureBy('user',
participant.user.resource_uri); // for each participant, update their
position on the map
                    if(f) {
                        var pt = new OpenLayers.Geometry.Point(
                            participant.where.coordinates[0],
                            participant.where.coordinates[1]
                        ).transform(gm, sm);

                        f.geometry.x = pt.x;
                        f.geometry.y = pt.y;
                    }
                    else {
                        f = new OpenLayers.Feature.Vector(
                            new OpenLayers.Geometry.Point(
                                participant.where.coordinates[0],
                                participant.where.coordinates[1]
                            ).transform(gm, sm), participant);

                        f.style = {
                            fill : true,
                            fillColor : '#ff6666',
                            strokeColor : '#ff6666',
                            strokeWidth : 1,
                            fillOpacity : 0.6,
                            graphic : true,
                            graphicName : 'cross',
                            fontColor : '#000000',
                            fontWeight : 'bold',
                            fontFamily : 'Helvetica, Arial, sans-serif',
                            fontSize : '9pt',
                            pointRadius : 5,
                            label : participant.user.username,
                            labelAlign : 'l',
                            labelXOffset : 7
                        };
                        f.attributes = participant;
                        f.user = participant.user.resource_uri;
                        participantsLayer.addFeatures([f]);
                    }

                    var display_name = participant.user.first_name ?
(participant.user.first_name + ' ' + participant.user.last_name)  :
participant.user.username;
                    var heartbeat_time = new
Date(participant.last_heartbeat);
                    var email_link = $("<a class='user_email'
data-role='button' data-mini='true' href='mailto:" + participant.user.email
+ "'>email</a>");

                    var participant_name = $("<li></li>")
                            .append($("<a class='username' href='#'>" +
display_name + "</span>").data('user', participant.user.resource_uri))
                            .append($("<span class='user_heartbeat'>" +
heartbeat_time.toTimeString().substring(0,5) + "</span>"))
                            .append(email_link);

                    $("#participant_list").append(participant_name);
                });

                participantsLayer.redraw();

And then added it to this map:

                    var baseLayer = new OpenLayers.Layer.Google("Google
Terrain", {type: google.maps.MapTypeId.TERRAIN, numZoomLevels: 20});
                    map = new OpenLayers.Map({
                        div: "map",
                        theme : null,
                        projection: sm,
                        numZoomLevels: 18,
                        controls: values(controls),
                        layers: [baseLayer, annotationLayer,
participantsLayer]
                    });
                    newCenter = new
OpenLayers.LonLat(data.center.coordinates[0], data.center.coordinates[1]);
                    lastCenter = newCenter.clone();

                    map.maxExtent = baseLayer.maxExtent;
                    map.setCenter(newCenter, data.zoom_level);
                    annotationLayer.projection = sm;
                    annotationLayer.maxExtent = map.maxExtent;
                    participantsLayer.maxExtent = map.maxExtent;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120801/ddd57c4a/attachment-0001.html>


More information about the Users mailing list