asked on
<body onload="init()" >
ASKER
<?php
/*
Plugin Name: Open Layers
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: 1.0
Author: Trevor1940
Author URI: http://URI_Of_The_Plugin_Author
License: A "Slug" license name e.g. GPL2
*/
function load_ol_stuff(){
wp_enqueue_script("jquery");
wp_enqueue_script('openlayers',
"//openlayers.org/api/OpenLayers.js","2.0",false);
wp_enqueue_script('OSM',
WP_PLUGIN_URL. "/OpenLayers/js/ol.js",
array('openlayers'),'1.0',false);
} // end load stuff
// load scripts required for plugin
add_action('get_header',load_ol_stuff);
function get_map(){
$html = <<<HTML
<div style="width:400px;height:400px;" id="draw-map-here"></div>
HTML;
echo $html;
}
add_shortcode( 'get-ol-map', 'get_map' );
jQuery(function($){
init();
});
function init(){
// alert("Hello word");
map = new OpenLayers.Map('draw-map-here');
originalOSM = new OpenLayers.Layer.OSM("OpenStreetMap");
map.addLayers([originalOSM]);
map.setCenter(new OpenLayers.LonLat(96.33899700000126,2.4700000000000246).transform(new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()), 10);
;}
ASKER
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
ASKER
I Assume I would need to will enqueue JQUERY before my script?