[OpenLayers-Users] Re: marker can be created from feature?

ggarcia ggarcia at ihman.com
Thu Aug 4 05:33:05 EDT 2011


@JK
You are right man! The same happen to me.

I was looking to try to use OpenLayers.Feature and OpenLayers.Feature.Vector
to create a Marker because at first it look like the best practice:
1) You can tunning your marker
2) Adding Markers instead a Vector you get properly renders

If you wanna use OpenLayers.Feature:

1)
[CODE]

  var map_OpenLayers = new OpenLayers.Map("map");
  
  /* load your map */
  
  var map_markers= new OpenLayers.Layer.Markers( "Markers" );

  map_OpenLayers.addLayer(map_markers);

[/CODE]

2)
[CODE]

  var feature = new OpenLayers.Feature(map_markers, lonlat);
  feature.data.icon = new OpenLayers.Icon("img/light.png", new
OpenLayers.Size(53,59), new OpenLayers.Pixel(0,0)); 
  
  var marker = feature.createMarker();

  map_markers.addMarker(marker);

[/CODE]

If you wanna use OpenLayers.Feature.Vector:
"createMarker" returns null:

....
So if you know already how to solve this or someone is in a similar
situation and wanna comment, any help will be apreciated!

ggarcia

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/marker-can-be-created-from-feature-tp6451665p6651992.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list