Hello to everybody I'm newbie using Openlayers. After googling for a week and not find solution I have signed this list, I hope someone has asimilar problem and could help me a little bit xD

I would like to know if there is a way to add a Marker using pixels. I know already that we can use this:

var pixel = new OpenLayers.Pixel ( posx , posy );
var lonlat = map_OpenLayers.getLonLatFromPixel ( pixel );

The problem is that If I make zoom during the insertion of a new marker I get a wrong positioning. I need a factor between my map size and the OpenLayers map container... anyway.. I don't want you to get lose with this xD I just would like to use pixel everywhere, no more lonlat, that would make me so happy! I had success with Vector instead of Marker, using Geometry.Point, but Vector has a big problem -> If you drag with the mouse to move into your map you will not see element vector painted till you unclick the mouse, here you can see it:
http://openlayers.org/dev/examples/sundials.html
(make sure you have a sun outside your viewarea and then drag the map to try to see the sun again)

Now do the same with Markers (you will notice that you always see your markers when you are dragging)
http://openlayers.org/dev/examples/markers.html

if it can be of any use here is my code:
// MAP

// Bounds
var map_OpenLayers_bounds = new OpenLayers.Bounds(0.0, -10000, 20000, 0.0);

// Options
  var options = {
    maxExtent: map_OpenLayers_bounds,
    maxResolution: 64.000000,
    numZoomLevels: 7
  };

  // Map
var  map_OpenLayers = new OpenLayers.Map("map", options);


// MARKER

// Transformation from pixel to lonlat
  var pixel = new OpenLayers.Pixel(posx,posy);

  var lonlat = map_OpenLayers.getLonLatFromPixel(pixel);

// Feature
  var feature = new OpenLayers.Feature(map_markers, lonlat);
  feature.closeBox = true;
  feature.data.popupContentHTML = popupContentHTML;
  feature.data.overflow = false;
feature.data.icon = new OpenLayers.Icon("img/light.png", new OpenLayers.Size(53,59), new OpenLayers.Pixel(0,0));

// Marker
  var marker = feature.createMarker();

  map_markers.addMarker(marker);
.....

Thanks in advance!!!
PoorNewbie xD
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to