[OpenLayers-Users] cakephp openlayers

emmexx emmexx at tiscalinet.it
Fri Nov 18 06:14:18 EST 2011


Il 11/18/2011 11:24 AM, Sarel scrisse:

> I read your post and want to ask for some help. I am new to cakephp and am
> trying to get openlayers working. I have extracted al the js into seperate file
> under webroot->js.
> I have placed the mapping container (<div>) on default.ctp along with link to js
> file. BUt openlayers map not displaying
> 
> What Im I doing wrong?

You must put the script tag in the head block of the page, as you would
do for a normal html page.
You can do it 2 ways:
- put the tag inside your layout file (app/views/layouts/yourLayout.ctp)
 e.g.:
echo $javascript->link('openlayers.js');

- put the tag inside your page (app/views/yourmodel/yoyrpage.ctp)
e.g.:
$javascript->link('OpenLayers-2.11/OpenLayers.js',false);

You need to change the path to the openlayers file, of course. And you
need to write some javascript code do load layers, map and so on.
I put that code at the end of the .ctp file:

<script type="text/javascript">
	Event.observe(window, 'load', function() {
		var map = Openlayers...
		and so on
	});		
</script>

Bye
	maxx


More information about the Users mailing list