Jump to content

Module is not working even with the same php code


Recommended Posts

Hi,

I have a some codes in php which is working fine(with html,php,jQuery). In this I have used

 Gmap3 jQuery plugin

files to show google map. The work of this code is when page is loaded then googlemap will be shown inside a div which id is map.For that my code looks like this

 

<script type="text/javascript" src="js/jquery.js"></script>
 <script type="text/javascript" src="js/gmap3.min.js"></script>  
 <script type='text/javascript' src='http://maps.googleapis.com/maps/api/js?sensor=false'></script>
 <script type="text/javascript">
function loadInitMap() {
if(typeof gMap == 'undefined') {
  //// CREATES A MAP
  gMap = jQuery('#map');
  gMap.gmap3({
	map: {
	  options: {
		zoom: 2,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		mapTypeControl: true,
		mapTypeControlOptions: {
		  style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
		},
		navigationControl: true,
		scrollwheel: true,
		streetViewControl: false
	  }
	}
  });
}
 }

 </script>
 <body onLoad="loadInitMap();">
 <div id="map" style="padding:20px; width: 50%; height: 400px; float: left; position: relative; border:1px dashed #ccc;"></div>
 </body>

 

Now all these are working fine with html,php, jQuery.

Now I want to use this in prestashop as a module. But remember I want to work this within admin panel. Means when someone will go inside the module from admin it should show the googlemap. So for that I did like this

class MapInfo extends Module {
	  public function __construct() {
	  ------------------------------
	  ------------------------------
	  }

	  public function install() {
	  ---------------------------
	  ---------------------------
	  }

	  public function uninstall() {
	  -------------------------------
	  -------------------------------
	  }

	  public function getContent() {
	  }

	  private function _displayForm() {
	  //here all the form elements and input type is defined
	  //here all the external js and css is linked
	  //For my case I have linked all the necessary files

  $this->_html .= '
	<link rel="stylesheet" href="../modules/mapinfo/css/style.css" />
	<script src="../modules/mapinfo/js/gmap3.min.js" type="text/javascript" charset="utf-8">
	<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
  ';
	//Here I have linked the necessary files
	//Now I want the piece of jQuery code to be executed for google map
$this->_html .= '
<script type="text/javascript">
function loadInitMap() {
if(typeof gMap == 'undefined') {
  //// CREATES A MAP
  gMap = jQuery('#map');
  gMap.gmap3({
	map: {
	  options: {
		zoom: 2,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		mapTypeControl: true,
		mapTypeControlOptions: {
		  style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
		},
		navigationControl: true,
		scrollwheel: true,
		streetViewControl: false
	  }
	}
  });
}
 }
</script>
';
 //Now I want to show the google map when the page is loaded for that I have taken div with id map
$this->_html .= '
<div id="map" style="padding:20px; width: 50%; height: 400px; float: left; position: relative; border:1px dashed #ccc;"></div>
';
	  }
	}

 

But after all this my codes are not working at all. Another query I have is in the code(the topmost part of refernced code) I have used

loadInitMap() 

function inside

onLoad body

. Thats why that is working when page is loaded. But here I can't load the function

loadInitMap()

with

 onLoad body

as I don''t have body here ;).

So can someone kindly help me here. I am totally confused here. Any help,suggestions or any referenced link will be really helpful.

Edited by prestashop_newuser (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...