1
votes

My searching has turned up virtually nothing. All of the documentation I can find is for the Drupal 6 version. I need to figure out how to render an Openlayers map programmatically (using the openlayers_render_map function, I assume). Ultimately I want to create with the form API a map to select between multiple locations that match a search, so that I can get the canonical address and a WKT string describing the exact location.

This is a rather open-ended question, and what I really want is a link to some well-written documentation. However, as I'm coming to the conclusion that no such thing exists, a more specific question would be: how do I design an Openlayers map in PHP code and render it in an arbitrary template? It will not display data stored in nodes, or even anywhere persistent at all, so using Views is not an option. Additionally, how can I begin to write Javascript that interacts with the map in order to select certain locations or retrieve the currently selected location?

3
Hi, I have the same question you have, I posted your question in the Drupal forum looking for some help. drupal.org/node/1955036 - Jose Daniel

3 Answers

1
votes

To render a map:

$map = openlayers_map_load('my_map');
$output = openlayers_render_map($map->data,$map->name);

To Interact with map in js:

var ol_map = $('.openlayers-container .openlayers-map').data('openlayers');
0
votes

Are you sure that using views isn't an option? Bear with me as I suggest a crazy idea:

Make a map view, where the map itself accepts lat/lng as arguments (or some other geo value of your choosing) then make a map data view that doesn't really contain anything meaningful at all. Link 'em up. Then send your map page arguments from your geocoder directly.

I am working on something similar with limited success, but it just feels like something that should be possible...

0
votes
$map = openlayers_map_load('your_map');
$map->data['layer_activated']['your_layer'] = 'your_layer';
$map->data['layers']['your_layer'] = 'your_layer';
$map->data['behaviors']['openlayers_behavior_zoomtolayer']['zoomtolayer']['your_layer'] = 'your_layer';    
$output = openlayers_render_map($map->data,$map->name);