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

pgr1973 pgr1973 at gmx.de
Sun Apr 10 10:29:27 EDT 2011


After quite some trial&error I got a solution (working with the openlayers
module for Drupal and Drupal6):

[...]
  // lebende OpenLayers Karte aus dem jQuery.data Teil holen
  var jdol = $('#openlayers-cck-widget-map-field_gp').data('openlayers');
  
  // Kartenzentrum auf eingegeben Werte und Zoomstufe 15 setzen
  jdol.openlayers.setCenter(new OpenLayers.LonLat(lonIn,
latIn).transform(jdol.openlayers.displayProjection,
jdol.openlayers.projection), 15);
  
  // Feature aus den eingegebenen Werten bauen und auf den Featurelayer
hinzufügen
  var inputFeature = new OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Point(lonIn.toFixed(12),
latIn.toFixed(12)).transform(jdol.openlayers.displayProjection,
jdol.openlayers.projection));
  var featuresLayer = jdol.openlayers.layers[3];
  featuresLayer.addFeatures(inputFeature);
[...]

The inserts an input point on the input-map at the positions latIn/lonIn
(values taken from the input-form, the user has entered).
'#openlayers-cck-widget-map-field_gp' is dependent on the content-type one
has created inside drupal (has another id with different content-type and
different field-name) and 'layers[3]' from 'jdol.openlayers.layers[3]' is
the layer with the drupalID 'openlayers_drawfeatures_layer' but I couldn't
get it via the drupalID, so I chose the absolute way. Which may be different
depending on the configuration of the input-map of the drupal
openlayers-module.

Regards Paddy



--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/How-can-I-set-a-point-on-the-Input-Map-via-JS-tp6251457p6258814.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list