AW: [OpenLayers-Users] How can I *set* a point on the Input-Map via JS

Arnd Wippermann arnd.wippermann at web.de
Thu Apr 7 16:58:19 EDT 2011


Try this

var geometry = OpenLayers.Geometry.fromWKT("POINT(2580000 5680000)");
var feature = new OpenLayers.Feature.Vector(geometry);

vectorlayer.addFeatures([feature]); 

Arnd

-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Patrick
Grochowy
Gesendet: Donnerstag, 7. April 2011 22:31
An: users at openlayers.org
Betreff: [OpenLayers-Users] How can I *set* a point on the Input-Map via JS

Hi Folks,

I'm a little bit lost inside all the different js functions,
drupal.behaviours, js-helper-functions and so on of the OpenLayers-Module
(6.x-2.0-alpha10) on Drupal 6. I have the module running, users can set
points to the map with their mouse, Drupal is saving the stuff and that part
works quite well (take a look at www.geomnesia.de - only in german at the
moment).

Now I want to add the possibility, that users can set the point by
typing/pasting in the latitude and longitude by themselves. So I added
(that's running on a local test-system it's not online now) two fields to
the form via jquery for the input and now want to add the point in the
input-map at that coordinates via js. But how can I do that, the docu
(module-docu and also openlayers doco or openlayers examples) says nothing
about that.

For instance:

Drupal.openlayers.addFeatures("GEOMETRYCOLLECTION(POINT(" +
lonIn.toFixed(12) + " " + latIn.toFixed(12) + "))" );

or

Drupal.behaviors.openlayers_behavior_drawfeatures("GEOMETRYCOLLECTION(POINT(
" 
+ lonIn.toFixed(12) + " " + latIn.toFixed(12) + "))" ); (lonIn and
latIn being the values, the user entered into the fields) inside my js does
nothing.

Which function is called in OpenLayers or the Drupal.openlayers, when a user
is clicking on the map and setting the point? And how can I access this
function, so that my OpenLayersInputMap thinks the user has set the point
and puts it on the position the user has entered?

Would be nice if someone could give a hint how to do that or has done
something similiar and can help me with this problem.

Regards Paddy

_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list