Support » Plugins » Hacks » google map in admin section

  • Resolved mgargiullo


    I’m trying to get a google map to display on an admin menu on a plugin I’m writing. When I view the source of the admin page, I can se the javascript for the map, but the map is never generated. Is there a trick to this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • idontknowhowtousewordpress


    Try using Bing Maps?

    No… Not Bing maps.

    So here’s the code on the admin page:

    function mrg_test_Add_Page() {
    	if ( !current_user_can( 'manage_options' ) )  {
    		wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    	<script type="text/javascript">
    	jQuery(document).ready(function($) {
    	var map;
    	var geocoder;
    	var position;
    	function mrgtestInitialize() {
    			//geocoder = new google.maps.Geocoder();
    			var latlng = new google.maps.LatLng(40.7142, 74.0064);
    			var mapOptions = {
    		    	zoom: 8,
    		    	center: latlng,
    		    	mapTypeId: google.maps.MapTypeId.ROADMAP
    			map = new google.maps.Map(document.getElementById("map-canvas-1"), mapOptions);
    	<div id="map-canvas-1"> </div>


    simple question…don’t hate me for this, but is your javascript up to date?

    Also have this:

    add_action( 'admin_enqueue_scripts', 'mrg_test_head' );

    and this:

    function mrg_test_head() {
    	<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    	wp_register_script('mrg_test_google_js_api', "");
    	//wp_register_script('mrg_test_functions', mrg_test_PLUGIN_DIR . '/functions.js');
    	wp_enqueue_script('mrg_test_functions',plugins_url('/functions.js', __FILE__));

    So the google API is loaded.

    “simple question…don’t hate me for this, but is your javascript up to date?”

    Honestly, not sure what you mean. The google api javascript is from google’s v3 sample code site. If I put it on its own, it loads fine and displays the map. Like above, the map code is loaded into the DIV, but not displayed.

    ok… disregard… I forgot that I have to set the height of the div so the map will show.

    Adding this allows it to show.

    width: 500px;
    height: 400px;

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘google map in admin section’ is closed to new replies.