Todays note….
function init_google_map(){wp_enqueue_script(‘google-maps’ , ‘http://maps.google.com/maps/api/js?sensor=true’ , false , ‘3’);}add_action(‘init’, ‘init_google_map’);
function loadmap(){// register your script location, dependencies and versionwp_register_script(‘custom_script’,get_bloginfo(‘url’) . ‘/wp-content/themes/gdirectory/gdirectory.js’,false,‘1.0’ );// enqueue the scriptwp_enqueue_script(‘custom_script’);}add_action(‘init’, ‘loadmap’);function init_google_map(){wp_enqueue_script(‘google-maps’ , ‘http://maps.google.com/maps/api/js?sensor=true’ , false , ‘3’);}add_action(‘init’, ‘init_google_map’);
function loadmap(){
// register your script location, dependencies and version wp_register_script(‘custom_script’, get_bloginfo(‘url’) . ‘/wp-content/themes/gdirectory/gdirectory.js’, false, ‘1.0’ ); // enqueue the script wp_enqueue_script(‘custom_script’);}add_action(‘init’, ‘loadmap’);
3. Add Top Menu And Page
add_action(‘admin_menu’, ‘business_menu’);
function business_menu(){
add_menu_page(‘Business Profile’, ‘Business Profile Page’, ‘5’, ‘business_page’, ‘business_page’);
}function business_page(){
echo ‘<div class=”wrap”>’;
echo ‘
<div>
<h2>Google Maps API</h2>
<div id=”map_canvas” style=”width:500px; height:500px”></div>
‘;
echo ‘</div>’;
}
4. Javascript Page
google.maps.event.addDomListener(window, “load”, initialize);
function 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);
}