我有一个带有geofield的内容类型。我正在使用OpenLayers Map作为输入小部件。该地图允许用户放置标记并将其填充GEOFIELD与LON / LAT坐标。然而，在某些情况下，优选地手动输入LON / LAT而不是使用地图。
如何在节点编辑表单中提供一个选项，以动态切换从OpenLayers映射到Lon / LAT的地理区域的显示小部件，或者从LON / LAT到地图？
I have a content type with a geofield. I'm using an Openlayers Map as the input Widget. The map allows the user to place a marker and it populates the geofield with the lon/lat coordinate. In some cases, however, it would be preferred to input the lon/lat manually as opposed to using the map.
How would you provide an option in the node edit form to dynamically switch the display widget for the geofield from the Openlayers map to lon/lat, or from lon/lat to a map?
The use case you describe is specific in nature, but the question you actually asked in the title is more general purpose. Ixe2x80x99m answering the question in the title.
To the best of my knowledge, there is not at present an Input Widget Switcher module for Drupal 7 or earlier, but there really needs to be. There are similar modules such as Display Suite for altering the displayed output of a node, including using different display formatters (example: showing the same date field as a short date format in a Teaser and as a long date format in a full node display), but nothing analogous for node input form widgets.
Drupal 8 has the underlying structure needed to implement something like this, known as Form Modes (basically the input form equivalent of View Modes such as Full vs. Teaser, which Display Suite builds on). But while there is a UI for creating them, there is not at present to the best of my knowledge an ability to use them or switch between Form Modes in core.
That said, the Form Mode Control module for D8 does seem to provide this ability. It allows switching between Form Modes based on Role or Permission and on Node (or Entity) Creation vs. Modification (for instance, on Creation the Widget for a GeoField might be Lat/Long with HTML5 GPS Geolocation enabled, but on Modification switch to a different Form Mode that uses, say, OpenLayers Map Widget so that the already-existing location marker can be moved on a map).
Therexe2x80x99s also the similar Form Mode Manager module (also D8 only) that works a bit differently, but itxe2x80x99s only in Alpha at the time of this writing, while Form Mode Control is in Release Candidate 2 and thus better for production sites.
I'm not sure you are looking for the exact same thing but have a look here https://drupal.org/sandbox/GwenMahe/2055375 I am still developing it, so if you notice some bug it's because it's not perfect yet !