Tuesday, October 12, 2010

Drupal + OpenLayer + Apollo


1. At Administer > Site building > Modules, enable the PHP filter module.

2. <script src="http://localhost:8080/apollo-client/OpenLayers.js"></script>

<?php
drupal_add_js(
'$(document).ready(function(){

var map = new OpenLayers.Map("myWorldMap");

var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://don_laptop:8080/erdas-apollo/vector/WORLDWIDE",
{layers: "cntry98gen02"}
);

map.addLayers([wms]);
map.zoomToMaxExtent();
});',
'inline'
);
?>

<div id="myWorldMap" style="width: 600px; height: 300px">
</div>


3. Also I needed to avoid cross-domain error because I have AJAX request going from localhost:8082 (drupal) to localhost:8080 (erdas-apollo)

ProxyRequests Off
ProxyPass /apollo-json http://don_laptop:8080/erdas-apollo/catalog/content/search.json
ProxyPassReverse /apollo-json http://don_laptop:8080/erdas-apollo/catalog/content/search.json

No comments:

Post a Comment