I'm learning how to build a google maps plugin. (I know that there are plugins that add Google Maps, but I'd like to be able to adapt the code to my needs. And it's fun to learn).
Unfortunately, I'm not getting a map after inserting my short code. This is the main php file of the plugin:
<?php
/*
Plugin Name: Lax Google Map Plugin
Plugin URI: http://www.mysite.com
Description: Make Map
Version: 1.0
Author URI: http://www.mysite.com
*/
function lax_google_map_init() {
wp_enqueue_script('google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false');
}
add_action('init', 'lax_google_map_init');
function lax_google_map_init_js() {
wp_enqueue_script('lax_google_map_script', plugins_url('js/lax_google_map_script.js', __FILE__), array('google-maps'));
}
add_action('init', 'lax_google_map_init_js');
function lax_google_map_maker($atts,$content=null) {
$output = '<div id="map_canvas" style="width:100%; height:100%"></div>';
return $output;
}
add_shortcode('lax-google-map', 'lax_google_map_maker');
?>
In the javascript file, I've got:
jQuery.noConflict();
jQuery(document).ready(function($) {
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);
});
I'm not getting an error. It doesn't do anything. Any suggestion as to what I'm doing wrong? I want to get a basic map working and then I should be able to add more functionality later. Thank you.
-Laxmidi