Hello again,

im still using drupal 6.16 and the latest dev version from 11. july and now i get a js error "google is not defined "

i downloaded the latest mapstraction via svn and checked if all js files are in teh right folder (sites/all/modules/mapstraction/mapstraction/source).

here is the js part

mxn.register('googlev3', {	

Mapstraction: {
	
	init: function(element, api){		
		var me = this;
		if ( google && google.maps ){
			// by default add road map and no controls
			var myOptions = {
				disableDefaultUI: true,
				mapTypeId: google.maps.MapTypeId.ROADMAP,
				mapTypeControl: false,
				mapTypeControlOptions: null,
				navigationControl: false,
			        navigationControlOptions: null,
				scrollwheel: false
			};

i also clear the cache and run the dbupdate, the error still exits.
also the neseccary js files are implemented (no js aggregation).

<script type="text/javascript" src="/sites/all/modules/mapstraction/mapstraction/source/mxn.js?M"></script>
<script type="text/javascript" src="/sites/all/modules/mapstraction/mapstraction/source/mxn.core.js?M"></script>
<script type="text/javascript" src="/sites/all/modules/mapstraction/mapstraction/source/mxn.googlev3.core.js?M"></script>
<script type="text/javascript" src="/sites/all/modules/mapstraction/mapstraction.drupal.js?M"></script>

Do you have a clue?
I've no idea anymore.

CommentFileSizeAuthor
#6 mapstraction.module.patch393 bytesjoelstein

Comments

skybow’s picture

Stuck on exactly the same issue: None of the map providers seem to work.
Does anybody know the SVN revision number that worked last with the 2-dev branch?

levelos’s picture

Status: Active » Postponed (maintainer needs more info)

It must be some type of an issue with the placement of the JS files. Have you used a tool like firebug to ensure you're actually loading the required JS files?

You may want to look at http://saveourgulf.org/observations as an example. It's using the latest version of the module. You can see the js files as well, e.g., http://saveourgulf.org/sites/all/modules/contrib/mapstraction/mapstracti....

You want the latest from SVN trunk. HOWEVER, the Mapstraction library just moved to Github, http://github.com/mapstraction/mxn. I'll updates the docs to reflect this.

skybow’s picture

I'm still investigating this (debugging is cool!) but I haven't found a solution yet due to time limitations.
For some reason the argument names for the template file in the theme registry for "mapstraction_map" get messed up. I.e. instead of putting the source code for loading the script into the variable "api_script" it will be loaded into "view" resulting in the template file not being able to emit the script location resulting in not loading the google maps js file(s).

Issue #484712: use templates instead of theme functions pointed me to begin to understand what's going wrong.

"Stay tuned. We'll be right back after these messages..."

iTiZZiMO’s picture

Hi loubabe

i had checked the js file . see my first post. it seems that the js files are in the wrong order now and the mapstraction drupal module doesnt consider this.
maybe ..? please also look at the first code part at the posting. firebug says that the google class / variable is not defined.

skybow’s picture

@2primes: Your description perfectly matches what I experienced. So if you have the same issue as I do, the google script is not loaded because it is not emitted properly by the template file.

On page "http://saveourgulf.org/observations" you'll find the following lines, that are emitted by the "mapstraction-map.tpl.php" file:

  <div class="view-content">
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <div id="mapstraction-reports-page_1" style="width: auto; height: 400px;"></div>    
  </div>

You should check in the source code of your site and look for something similar to the <div id="mapstraction-reports-page_1" style="width: auto; height: 400px;"> line. If you find it and the "width" and "height" styles are empty and you don't find a "script" tag, you probably have the same problem as I do.

I'll look into this later today, but now I gotta start work...

joelstein’s picture

Title: js error google is not defined (googlev3 and gmap (v2)) » Theme file not receiving arguments properly
StatusFileSize
new393 bytes

I am confirming what skybow said in #3. In the "mapstraction-map.tpl.php" theme file, the variables were not defined. In fact, the values were there, but they were assigned to what looked like Views variables.

The solution I tried, which is working for me, is to adjust the Views plugin so it doesn't look for that theme file (it doesn't need it, because when the view gets rendered, it calls mapstraction_render_map(), which returns the themed map). See the attached patch. You may need to clear your caches to get this to work.

joelstein’s picture

Status: Postponed (maintainer needs more info) » Needs review
levelos’s picture

Status: Needs review » Fixed

Thanks joelstein, you're correct, the Views plugin doesn't need the theme file. That's left over from the old architecture and wasn't removed. I'm still not exactly clear, though, on why it still works fine in some cases and not others. Patch is committed to the 2.x branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.