Hello,

I am not quite sure if this solves your problem, but you need to transform your features because your map is in EPSG:900913

transform(
      new OpenLayers.Projection("EPSG:4326"),
      map.getProjectionObject() )

For the popup "problem" maybe this example helps you:

http://openlayers.org/dev/examples/select-feature-openpopup.html

Best regards,
Chris




Am 03.02.2011 19:42, schrieb Puneet Kishor:
I am using the following code, but no deal. What wrong tree am I barking up here? Also, I would like to add popup windows to each marker to show the "cn" and "nt" values in the popup. Pointers to that would also be muchly appreciated.

var C = {
  "init": function() {
    var map = new OpenLayers.Map("map");
    var gphy = new OpenLayers.Layer.Google(
      "Google Physical",
      {"type": google.maps.MapTypeId.TERRAIN}
    );

    map.addLayers([gphy]);

    C.vector(map);

    /*
    Google.v3 uses EPSG:900913 as projection, so we have to
    transform our coordinates
    */
    map.setCenter(new OpenLayers.LonLat(0, 0).transform(
      new OpenLayers.Projection("EPSG:4326"),
      map.getProjectionObject()
    ), 2);
  },

  "vector" : function(map) {
    var vector = new OpenLayers.Layer.Vector("Vector Layer");

    var features = [];
    for (var i = 0; i < C.points.length; i++) {
      features.push(
        new OpenLayers.Format.GeoJSON({
          "internalProjection": map.baseLayer.projection,
          "externalProjection": new OpenLayers.Projection("EPSG:4326")
        }).read({
          "type"    : "Feature",
          "id"    : i,
          "crs"     : null,
          "properties": {},
          "geometry"  : {
            "type"      : "Point",
            "coordinates"   : [C.points[i].lo, C.points[i].la]
          }
        })
      );
    }

    vector.addFeatures(features);
    map.addLayer(vector);
  },

  "points": [
    {"ci":1,"cn":"Foo","la":34.5167,"lo":69.1833,"nt":"Good to be foo"},
    {"ci":2,"cn":"Bar","la":41.3167,"lo":19.8167,"nt":"Bla bla bar"},
{"ci":3,"cn":"Baz","la":36.7500,"lo": 3.0500,"nt":"Hello, my name is Baz"},
    ..
  ]
};




_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to