Forums

Apis an choronoform

fabaya 16 Apr, 2010
Hello choronoformers:

Due the limitation of not using <html> - <body> - <head> - <form> - <script> -<style> tags in the boxes of codes I dont know how to embbed the next API insert in chronoform:

 

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
        <script type="text/javascript">

        google.load("maps", "2");
        google.load("elements", "1", {packages : ["localsearch"]});
        </script>

        // Create a map
        var map = new google.maps.Map2(document.getElementById("map"));
        map.setCenter(new GLatLng(33.956461,-118.396225), 13);
        
        // Create a local search control and add it to the map
        map.addControl(new google.elements.LocalSearch());


This API is an example to add map control search in google map located in:
http://code.google.com/intl/es/apis/ajaxsearch/documentation/localsearch/index.html#_including_LSC

If anybody can help....

Thanks
GreyHead 16 Apr, 2010
Hi fabaya,

Try a quick search, I (and others) posted some Google Maps code here in the last few weeks.

Bob
fabaya 17 Apr, 2010
I found no answer on how to embbed <script> tags in a default tagged aplication. Thanks
GreyHead 18 Apr, 2010
Hi fabaya,

Please search here on addscript

Bob

[forumsb]addscript[/forumsb]
ozneilau 30 Jul, 2010
Hi Fabaya,

I managed to do this based on the PHP example at: http://forum.joomla.org/viewtopic.php?p=1933257 also shown below for convenience.

The code inserts required lines into the HTML header so you don't have to edit the template HTML.

Neil

<?php
$doc =& JFactory::getDocument();
$theScript = "<meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\" />\n";
$theScript .= "<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>\n";
$theScript .= "<script type=\"text/javascript\">\n";
$theScript .= "function MY_initialize() {\n";
$theScript .= "var latlng = new google.maps.LatLng(-34.397, 150.644);\n";
$theScript .= "var myOptions = {\n";
$theScript .= "zoom: 8,\n";
$theScript .= "center: latlng,\n";
$theScript .= "mapTypeId: google.maps.MapTypeId.ROADMAP\n";
$theScript .= "};\n";
$theScript .= "var map = new google.maps.Map(document.getElementById(\"map_canvas\"), myOptions);\n";
$theScript .= "//alert(\"Initializing...\")\n";
$theScript .= "}\n";
$theScript .= "</script>\n";
$doc->addCustomTag($theScript);
?>
GreyHead 30 Jul, 2010
Hi Neil,

That will work fine but is a bit more than is needed. Here's a more elegant version of the same thing.
<?php
$doc =& JFactory::getDocument();
$doc->addScript('http://maps.google.com/maps/api/js?sensor=false');
$doc->setMetaData( 'viewport', 'initial-scale=1.0, user-scalable=no' );
$script = "
function MY_initialize() {
	var latlng = new google.maps.LatLng(-34.397, 150.644);
	var myOptions = {
		zoom: 8,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
	//alert('Initializing...')
};
";
$doc->addSCriptDeclaration($script);
?>

Bob
ozneilau 31 Jul, 2010
Thanks Bob,

Yes, that is certainly more elegant! I will update my code accordingly!

Thanks,

Neil
This topic is locked and no more replies can be posted.