This one is part of META issue #1931138: Fixing all 'single marker' issues

Hi,

I´ve created a view that displays a gmap with a couple of locations. The view has a couple of exposed filters that default to ANY.

On initial display, the view with the gmap displays just fine. I get a map of with bubbles for the two node locations.

If I then simply click the APPLY button to refresh the view without changing the filter settings from the defaults that have just successfully displayed a map the little ajax whirling graphic displays and then the map disappears and is replaced by the text "Javascript is required to view this map". The only way I can get the map to redisplayt is by forcing a page refresh e.g. SHIFT Refresh.

This is using the latest gmap version. Gmaps appear just fine on nodes and other places I expect them to be.

I´m using the Sept 24 6.x-1.x-dev gmap version.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jasontanner’s picture

Also, no errors appear in firebug or the error console. I also get the same symptoms in CHrome, IE and Firefox.

Its possible that this might be related to http://drupal.org/node/313416 "Displaying a map in an AHAH result" ??

chlobe’s picture

Same problem here. Throws "Javascript is required to view this map." The view displays normally as a table, grid etc. Also tried reducing fields to 1 eg country.

Cheers

bdragon’s picture

To start with, make sure you're using at least views 2 RC4. There are some ajax problems in earlier versions..

jasontanner’s picture

Hi Bdragon,

Unfortunately, even after upgrading views from 6.x-2.0-rc3 to 6.x-2.0-rc4 I still get the same problem.

The gmap displays fine on first display but if I click the apply button on the filters the map is removed and the java script message appears.

The drupal log contains no errors and neither are any reported by firebug or the ff error console.

Can you suggest anything else I can do to investigate this further and gather useful information to debug this ?

chlobe’s picture

Hi

I second that, same problem after uprgrading to rc4.

Any assistance gratefully received

atiras’s picture

No expert here, but I had this (or a very similar) problem and it was fixed -- CSS related, not Javascript. See #266595: "Javascript is required to view this map" in case that helps.

jasontanner’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc1

Hi Bdragon,

I've upgraded to gmap 6.x-1.0-rc1 and am using location 6.x-3.0-rc1 and views rc4 unfortunately I get the exact same symptoms.

The gmap displays perfectly on the view on the first display (and also if I re-click the link that displays the view page) but if I try to hit the Apply button on the exposed filters the AJAX whirly pic displays and then the gmap is removed and replaced with the "Java script is required" message - and no other errors are reported anywhere - not in firebug, not in the javascript console, and not in the drupal error log.

Could this be related to http://drupal.org/node/313416 "Displaying a map in an AHAH result" where both yourself and bevan hinted that there are likely to be problems with AHAH stuff ?

jasontanner’s picture

Temporary Solution: I turned of AJAX in the View Definition - which sucks - but at least I can now progress and await a fix.

bdragon’s picture

Yeah, the AJAX stuff and GMap don't get along very well, unfortunately. GMap wasn't designed to be rebootstrapped, and it will take a bit to get all the corner cases fixed.

Toddv’s picture

same issue - subscribing; elaborating: It seems that whether or not Ajax is on I cannot build a gmap view that has exposed options (eg: date, term). My work around is just to build views that are static to the year, or term, which works but it would be great to be able to select a range of years (in my case) and/or taxonomy terms.
It's pretty darn great as it is so I'm not complaining - thanks to the contributors for their work on this and associated modules. TV

mrfelton’s picture

same issue for me.

frdesign’s picture

Same issue here so I turned Views' ahah off as well, but at this point I'm so thrilled I can now get lat long from my custom country, city tables (thank you!!!!!) I can live with this issue until it's fixed :-)

Anonymous’s picture

Same Issue here, would love to help but definitely out of my depth. Let me know if I can help test or anything.

restyler’s picture

any news? subscribing

newtoid’s picture

looks like in some themes this works fine and not in others, in edit mode i see the maps but not in view mode

dan.crouthamel’s picture

I have the opposite problem. With the theme I'm using, and for only one particular content type, I see the map just fine in view mode, but not edit mode ... wish there was some consistency here :)

tonycpsu’s picture

Subscribing.

johan.jacobs’s picture

Hello,
I have the same problem.
But I'm not getting the error message all the time.

I get the Google map in the edit menu but on the node itself, I only see the coordinates "51° 1' 40.0512" N, 4° 28' 46.83" E"

JaceRider’s picture

Subscribing. It would appear that the javascript call that renders the map simply needs to be called again once the filter results have been returned.

3rdLOF’s picture

JaceRider:

Can you give a few more specifics on what you mean?

Nchase’s picture

Version: 6.x-1.0-rc1 » 6.x-1.x-dev

same problem here. Has anything yet came up to solve the issue?

JaceRider’s picture

Well, from my understanding (which may or may not be correct)... when the page is loaded, a bit of Javascript is called in order to call for the generation and display of the map. If this call fails for any reason, you will get a text message stating "Javascript is required to view this map."

Hence, on first page load, everything works fine as the javascript replaces the "Javascript is required..." text with the map. However, when you do an ajax replace of the map with views exposed filter, the javascript that generated the initial map does not get called again, and therefore all we are left with is "Javascript is required...".

Make sense? Unfortunately I haven't had the time to delve into the problem much more than this, but if I do come up with some time and can find a solution, I will certainly post it here.

j0k3z’s picture

any updates on this bug?

kvvnn’s picture

Lets get a solution for this.

Are there any functions we can manually fire to re-build the map? What happens to the GMap when we refresh the page? Can we make that happen on our own?

ari-meetai’s picture

Status: Active » Needs work

Same problem here. Temporarily solved as #8, by disabling Ajax on the view.

kvvnn’s picture

dev : kvn : i was thinking of the autocomplete not the map that had to initialize after load: "script type="text/javascript""Drupal.autocompleteAutoAttach();"/script"
kvn : Ah
dev : i will look to see if there is anything i did to make the map work after ajax. i do remember something about that.
kvn : bdragon mentioned that Gmap has issues w/ Ajax here : http://drupal.org/node/315236
"Druplicon" http://drupal.org/node/315236 =" GMap View, 2 Exposed Filters and the error "Javascript is required to view this map" =" GMap Module, User interface, normal, needs work, 2 IRC mentions
dev : kvn : : right. so basically you need to kick off the map initialize again on callback complete for the views filter
dev : there must be a hook for that
dev : or a javascript callback handler you can piggy back off of.
kvn : Thats what I'm looking for, but there is so much code I don't know what to try
dev : are you just using the Gmap plugin for the view?
kvn : yeah
dev : i would actually start with trying to look at the javascript. looking at the server side code will probably make your head spin.
dev : i would start by looking for the init function for the map in the javascript. see what i needs to build correctly (probably wont be too much cause the view probably passes all the data).
dev : then try to piggy back off that
kvn : any idea which js file?
dev : you just want to call that function (basically, cause i am guessing here) when the exposed filter comes back.
dev : let me look. your on drupal 6?
kvn : yeah
dev : or 5?
kvn : I'm assuming probably gmap.js
dev : k
dev : first off, do you have firebug installed?
kvn : yeah
dev : i would recommend it (console) if are working with javascript
dev : console.log(any_object) give you a great print out.
dev : im sure you have found that already
kvn : I haven't seen that actually
dev : i would expect to have to run the Drupal.gmap.setup(settings) function.
dev : in gmap.js
dev : line 60
dev : i would start there anyway.
dev : so try this.
dev : turn on console for your site.
dev : go to your view and do an exposed filter thing so the map goes away (im assumin thats the problem you are having?)
kvn : that as well as some other ajax refresh stuff
dev : then once it is gone, do this in the console... console.log(Drupal.gmap); and have a look at what is there.
kvn : okay, thank you
dev : kvn : : i would assume so
dev : you will probably have to find where the 'settings' are saved, but they are probably somewhere in the Drupal.gmap object and then runDrupal.gmap.setup( settings) and see what happens.
dev : i have not tried to solve this problem, so i am guessing a lot here, but this is how i would approach the problem.

newtoid’s picture

after creating/updating it is possible to view the map by enabling a block which displays the map

kvvnn’s picture

I think you are having a separate issue, DaveNewton. We can see the maps just fine, but when an Ajax refresh is processed, the maps unload but do not reload. Maybe I misunderstood you?

ctalley5’s picture

subscribing

jarchowk’s picture

subscribing

Bartezz’s picture

subscribing

chicagomom’s picture

I am getting this error on admin | settings |gmap as welll as on the view I created. Initially (before there were any nodes with data) I could see the map on the gmap settings page. Now all I see is the js message [under default map settings].

SocialNicheGuru’s picture

I get this error when:

I attached a gmap map to a table view exposed the filter
I goto the page
the map and table show up fine
when I select a value to filter, then press enter, I get "Javascript is required to view this map".

ctalley5’s picture

I was originally getting the same error when filtering... but the gmaps were showing just fine on nodes.

now I just started getting the error on a lot of plain old nodes as well... which were fine before

chicagomom’s picture

Never mind. My issue had to do with not having appropriate write permissions for IUSR on c:\windows\temp (IIS7 environ). Setting appropriate permissions solved that.

Bartezz’s picture

Think we need to change the title to something like;

GMap View, 2 Exposed Filters and the error "Javascript is required to view this map" upon AJAX update

People are using this thread for other bugs as well when this one is AJAX related, right?

kvvnn’s picture

Yes.

Bartezz’s picture

Title: GMap View, 2 Exposed Filters and the error "Javascript is required to view this map" » GMap View, 2 Exposed Filters and the error "Javascript is required to view this map" upon AJAX update

Here we go... title changed.

I've been firebugging away but I can't seem to find a solution to this.
Has anyone come closer to an answer to this bug?

Cheers

kvvnn’s picture

No, nothing I can find suggests we are any closer to a solution for this. I disabled Ajax on my maps.

PaulHruska’s picture

've been digging into this problem for a few days now, and I think I may have identified a work-around.
My specific setup is a compound view of a table, index, and gMap using the 'attachment' feature. (Your mileage may vary.)
After much capturing of IP traffic, and tracing through the code, I was able to verify that the proper gMap response is being returned by the Ajax call (by Views), and is indeed being injected into the browser DOM via the Views ajax_view.js script. It just isn't getting refreshed.

Thanks to bdragon in http://drupal.org/node/414752, the insertion of a 'map reset' seems to resolve the re-display problem (see fix-1).

However in my case, since the re-display is a sub-set of the original display (selection of an index item), the gMap persists in displaying markers that are no longer relevant. This is because the response returned from the server by the Ajax call 'merges' with the prior generation of the gMap. ( jQuery.extend(true,Drupal,{settings:{ etc... ). This has the effect of 'updating' the first few markers with the new information, and 'persisting' the remaining markers in the browser DOM data. Thus when the gMap is re-rendered there are markers for items that are no longer displayed (see fix-2).

Hope this helps...

fix-1:

in gmap.module:

  $o .= "/* <![CDATA[ */\n";
  $o .= 'jQuery(Drupal.gmap.unloadMap("'.$mapid.'"));';
  $o .= 'jQuery.extend(true, Drupal, { settings: '. drupal_to_js(array('gmap' => array($element['#map'] => $map))) ." });\n";

fix-2:

in gmap.js:

    unloadMap: function (mapid) {
      delete maps[mapid];
      if (Drupal.settings && Drupal.settings.gmap && Drupal.settings.gmap[mapid]) {
        delete Drupal.settings.gmap[mapid].markers;
      }
    },
Bartezz’s picture

Status: Needs review » Needs work
FileSize
836 bytes

Hi Paul,

I tested it immediately and it seems to work for me too... I've tested it Firefox (3.5.2 on XP SP3).
In Internet Explorer 7 (7.0.5730 on XP SP3) I think I had some cache problems, it didn't work at first but it does now!

You are the hero of the week!!!

Cheers

PS. I created a patch with your changes and attached it, not trying to steal your credits tho!!!

Bartezz’s picture

Status: Needs work » Needs review

Oops forgot to change the status...

JaceRider’s picture

Status: Needs work » Needs review

Excellent work PaulHruska!

It is so close -- however, I am running into an issue. On first execution of an ajax refresh, the map does correctly update. However, if I filter it again, I am back to square one.

The only thing that I am noticing that is different between the first call and the second, is unloadMap is getting called twice on the second.

Anyways, I'm going to play around with it and see if I can see what is going on -- but thanks again!

JaceRider’s picture

Further note on the issue... if I select a filter that returns no results, run the call, then select one that has results, the view fixes itself and the map is again displayed.

Lowgain’s picture

I have the same problem now with this fix working only once and then messing up.
Not sure if this will help you out at all, but in the gmap.module fix, I added a js alert before unloadMap is called. It alerts properly on page load and the first time you refresh, but the second/third/etc times you update the filter, the alert goes off twice in a row. Could this indicate the cause of the problem?

Bartezz’s picture

I've had some issues as well, best way to reproduce;

- Clear all cache and cookies (I use Firefox webdeveloper toolbar for this)
- Close browser and restart
- Surf to the page with your Gmap view
- Make a selection from exposed filters and click apply
:: no results are shown

- now without changing a thing do a CTRL+F5 hard reload
:: now it does show results with the same selected filters!

Will look into deeper on monday. Can you guys check if this is the case with your setup as well?

Cheers

Bartezz’s picture

Ok, found my problem. The reason it wasn't showing any markers was because gmap_markers.js and markerloader_static.js weren't loaded into head.
This was because I started my view empty by default (Howto is here: http://drupal.org/node/358546#comment-1492012)

So I added +dynmarkers to my view macro hoping this would solve the problem. But it didn't. So I checked the code for the reason and found it in gmap.module.

I've included a patch to enforce marker loading eventhough the view is empty but only when the macro is set to +dynmarkers.

Cheers

JaceRider’s picture

I am still having issues where it works the first time the view is applied... and then after that I'm back to the "Javascript is required" message.

Bartezz’s picture

The patch at #41 fixed that "Javascript is required to view this map" for me... Did you clean browser cache and Drupal's cache?
Maybe try to turn off every module that's not nessecary to run the view and see if it works, also try it in Garland and see what happens.

JaceRider’s picture

Bartezz, do you have your map set up as an attachment or is it the main element of the view?

Bartezz’s picture

Hi,

I have it as a block display with exposed filters in a separate block. Haven't tested it as a page display actually so maybe that's it!

Cheers

ctalley5’s picture

Works for me!!!! You're the man Paul!

Lowgain’s picture

any updates yet on the refreshing more than once issue?

Bartezz’s picture

Lowgain,

Are u using a block or a page display? I'm using a gmap block display and have no issues other then the one mentioned and fixed in #47....

Cheers

Bartezz’s picture

Lowgain,

Are u using a block or a page display? I'm using a gmap block display and have no issues other then the one mentioned and fixed in #47....

Cheers

Lowgain’s picture

my map is an attachment at the top of another block

Bartezz’s picture

Try it standalone... well just as a normal block...

Cheers

Lowgain’s picture

I'll give it a shot, but as my view needs to update the results in both the map and a list of the same content underneath, this may not fulfill the requirements of my task :S

JaceRider’s picture

I'm with Lowgain on this one. A simple block may work -- in fact -- I bet it does. But we need to figure out why it isn't working when the map is added as an attachment. I've poured over things and can't find the problem.

Lowgain’s picture

I really can't say what happened, but the problem seems to have solved itself! Once I'm finished completing the project I'll try to find time to backtrack and discover what fixed it.

kvvnn’s picture

Status: Reviewed & tested by the community » Needs review

Would this patch work for the CCK Location Field - Lat/Long Chooser map ?

I have a popup to add a node w/ a location field in it.

Update : the patch allows the map to be loaded via ajax, but there are other issues w/ selected a location from the Location CCK Coordinate chooser map going on, that I cannot isolate.

I'm also having a map disappear completely when using Ajax - Views Refresh in a Quicktabs setting. We might be missing some other Ajax issues within GMap with these patches.

I don't think I would change the status just yet, there are still issues at hand that this patch does not address (and maybe it shouldn't - the scope may be too broad here).

Bartezz’s picture

Status: Needs review » Reviewed & tested by the community

I reckon we can change the status of this post now, hopefully the patches will get committed soon!

Cheers

HnLn’s picture

Status: Needs review » Reviewed & tested by the community

Issue I have after implementing the fixes from #40 is if your result views is empty, you get nothing (seems ok), but if you then go back to all, the map is gone.

Bartezz’s picture

Try and set the empty text and include a gmap macro into this (make sure the input filtyer you are using for the empty text is gmap macro enabled).

I think your problem is that the gmap nessecary javascript isn't loaded on first page load because the result is empty, then if you update the view via Ajax the page doesn't know what to do with all the variables returned by views...

Cheers

morbiD’s picture

The patches fix the case where you start with at least one result at page load. However, as HnLn says in #63, if the page loads with an empty result set and you apply a filter, the "Javascript is required to view this map" error returns.

Bartezz's suggestion in #64 does not work for me - it loads a default gmap when there are no results, but that map then stays there regardless of what filter values you apply afterwards. It just doesn't update at all. You're basically replacing the error message with an empty gmap which still doesn't respond.

Changing status to "needs work" since I don't see a point in committing this until both use cases are covered i.e. starting with or without results.

Incidentally, the patch in #41 fails to apply against the current dev version because in gmap.module

$o .= '<script type="text/javascript">'."\n";
$o .= "/* <![CDATA[ */\n";
$o .= 'jQuery.extend(true, Drupal, { settings: '. drupal_to_js(array('gmap' => array($element['#map'] => $map))) ." });\n";
$o .= "/* ]]> */\n";
$o .= "</script>\n";

has become

drupal_add_js(array('gmap' => array($element['#map'] => $map)), 'setting');
jdidelet’s picture

Status: Reviewed & tested by the community » Needs work

Subscribing

morbiD’s picture

Hmm, apologies due to Bartezz - the problem I was experiencing in my last post was apparently due to my gmap.js somehow not being patched. All seems to be working great now that I've patched that file manually, so another thumbs up for getting it committed.

Seems like we just need an updated patch to take into account the changes in the current dev version and it'll be good to go. I'd reroll the patch myself but I'm not sure how to deal with those changes.

Bartezz’s picture

No worries :)

Kristen Pol’s picture

I applied the patches from #41 and #47 to the 1.0 version of gmap and THEY WORK BEAUTIFULLY!! I am a very very happy camper.

I hope these get into the module soon... I'll be happy to test a reworked version of the patch(es) with the latest dev if someone creates them.

Thanks!!
Kristen

nielt’s picture

How can the issue raised in #65 be addressed? The method for adding javascript to the page has changed completely.

Bartezz’s picture

You are welcome to do so...

morbiD’s picture

Personally, I've just reverted the javascript insertion code to the old style so that I can still apply the patch.

Anyone have any problems using the location picker at user/*/edit to set user locations? I get the "Javascript is required to view this map" error there because the code in the patch is apparently unloading the map at that path. Adding a condition around the code seems to fix it for me:

<?php
  $o .= '<script type="text/javascript">'."\n";
  $o .= "/* <![CDATA[ */\n";
  if (!preg_match('#\Auser/\d+/edit\z#', $_GET['q'])) {
    $o .= 'jQuery(Drupal.gmap.unloadMap("'.$mapid.'"));';
  }
  $o .= 'jQuery.extend(true, Drupal, { settings: '. drupal_to_js(array('gmap' => array($element['#map'] => $map))) ." });\n";
  $o .= "/* ]]> */\n";
  $o .= "</script>\n";
?>

Can anyone reproduce the problem I'm describing? It's always possible I've cocked up my installation somewhere so it would be useful if someone can confirm it.

BetaFlasher’s picture

I had the same issue with GMap as an attachment using Ajax - After applying exposed filters for the second time, "Javascript is required to view this map" showed instead of GMap.
I messed around this a lot and I couldn't find solution for this issue anywhere. But today is my lucky day and solved this issue by myself :)
The problem was with Views module -> "ajax_views.js". I use Views-2.6 (I downgraded Views because of empty content in GMap bubbles). First of all, I noticed that pager with Ajax works perfect and GMap shows all the time and that's why I tried to get how pager works in "ajax_views.js". I compared it with exposed filters and noticed that exposed filters have something missing. Exposed filters don't have these command lines:

$(view).filter(':not(.views-processed)')
        // Don't attach to nested views. Doing so would attach multiple behaviors
        // to a given element.
        .filter(function() {
          // If there is at least one parent with a view class, this view
          // is nested (e.g., an attachment). Bail.
          return !$(this).parents('.view').size();
        })
        .each(function() {

So, that's why I added lines mentioned above before command lines of exposed filters and as in pager, I changed this line: eval(callback)(view, response);
to this:
eval(callback)(target, response);
In overall, just replace these command lines in "views/js/ajax_views.js":

 // Process exposed filter forms.
     $('form#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'))
      .filter(':not(.views-processed)')
      .each(function () {
        // remove 'q' from the form; it's there for clean URLs
        // so that it submits to the right place with regular submit
        // but this method is submitting elsewhere.
        $('input[name=q]', this).remove();
        var form = this;
        // ajaxSubmit doesn't accept a data argument, so we have to
        // pass additional fields this way.
        $.each(settings, function(key, setting) {
          $(form).append('<input type="hidden" name="'+ key + '" value="'+ setting +'"/>');
        });
      })
      .addClass('views-processed')
      .submit(function () {
        $('input[type=submit]', this).after('<span class="views-throbbing">&nbsp</span>');
        var object = this;
        $(this).ajaxSubmit({
          url: ajax_path,
          type: 'GET',
          success: function(response) {
            // Call all callbacks.
            if (response.__callbacks) {
              $.each(response.__callbacks, function(i, callback) {
                eval(callback)(view, response);
              });
              $('.views-throbbing', object).remove();
            }
          },
          error: function() { alert(Drupal.t("An error occurred at @path.", {'@path': ajax_path})); $('.views-throbbing', object).remove(); },
          dataType: 'json'
        });

        return false;
      });

to these:

// Process exposed filter forms.
       $(view).filter(':not(.views-processed)')
        // Don't attach to nested views. Doing so would attach multiple behaviors
        // to a given element.
        .filter(function() {
          // If there is at least one parent with a view class, this view
          // is nested (e.g., an attachment). Bail.
          return !$(this).parents('.view').size();
        })
        .each(function() {
          // Set a reference that will work in subsequent calls.
          var target = this;
      $('form#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'))
      .filter(':not(.views-processed)')
      .each(function () {
        // remove 'q' from the form; it's there for clean URLs
        // so that it submits to the right place with regular submit
        // but this method is submitting elsewhere.
        $('input[name=q]', this).remove();
        var form = this;
        // ajaxSubmit doesn't accept a data argument, so we have to
        // pass additional fields this way.
        $.each(settings, function(key, setting) {
          $(form).append('<input type="hidden" name="'+ key + '" value="'+ setting +'"/>');
        });
      })
      .addClass('views-processed')
      .submit(function () {
        $('input[type=submit]', this).after('<span class="views-throbbing">&nbsp</span>');
        var object = this;
        $(this).ajaxSubmit({
          url: ajax_path,
          type: 'GET',
          success: function(response) {
            // Call all callbacks.
            if (response.__callbacks) {
              $.each(response.__callbacks, function(i, callback) {
                eval(callback)(target, response);
              });
              $('.views-throbbing', object).remove();
            }
          },
          error: function() { alert(Drupal.t("An error occurred at @path.", {'@path': ajax_path})); $('.views-throbbing', object).remove(); },
          dataType: 'json'
        });

        return false;
      });
  }); // .each function () {

This solution works like a charm with Views-2.6. If you test it with higher version of Views then please let me know how it works.

EDIT: I just noticed that map doesn't work if Views return empty results for the first time filtering. If Views return even one result for the first time filtering then with my solution GMap works OK. Any ideas for this?

Bartezz’s picture

Have a look at #47

BetaFlasher’s picture

Thank you! It really helped to solve my issue, now everything is working!
I applied your patch, added argument for GMap in Views to always show values and in empty text field I added GMap macro, so GMap shows all the time.

Anonymous’s picture

I tried the solution at #73 but it did not work for me with Views 2.8. I'll try downgrading to 2.6 but there are some features in 2.8 I want to keep

Anonymous’s picture

Using View 2.6 or Views 2.8
GMap 6.x-1.x-dev
Location 6.x-3.x-dev

Could not get the solutions proposed at #73 or #40 to work.

If I try #73 I get the 'Javascript is required to view this map.' message.

With #40, I replaced:

drupal_add_js(array('gmap' => array($element['#map'] => $map)), 'setting');

with

$o .= '<script type="text/javascript">'."\n";
$o .= "/* <![CDATA[ */\n";
$o .= 'jQuery.extend(true, Drupal, { settings: '. drupal_to_js(array('gmap' => array($element['#map'] => $map))) ." });\n";
$o .= "/* ]]> */\n";
$o .= "</script>\n";

and did the fixe to js/gmap.js

But when I use my filter, the AJAX spinner shows, spins, and never stops spinning

greenbeans’s picture

Having the same problem with AJAX paging.

kvvnn’s picture

Check this out : http://demo1.drupella.com/ajax-gmap

By default gmap views does not support ajax pagination and ajax exposed forms. This demo uses an additional custom module that provides these features.

I've contacted the website maintainers for support over here. I'd like to see their method of using Ajax w/ Gmaps.

greenbeans’s picture

@kevin riggen -- have you heard anything back from that site?

Fabianx’s picture

HI,

I got a nicely working solution, which can be implemented as a module (!), however I have not yet done so, due to time issues. :-)

First here is the patch, then I describe how the module would work:

In views/includes/ajax.inc:

diff --git a/public_html/sites/all/modules/views/includes/ajax.inc b/public_html/sites/all/modules/views/in
index cc6636c..ee72292 100644
--- a/public_html/sites/all/modules/views/includes/ajax.inc
+++ b/public_html/sites/all/modules/views/includes/ajax.inc
@@ -55,6 +55,9 @@ function views_ajax() {
           $object->status = TRUE;
           $object->title = $view->get_title();
           $object->display .= $view->preview($display_id, $args);
+         // Save settings: FIXME Custom module!
+         $js = drupal_add_js(NULL,NULL, 'header');
+         $object->settings=$js['setting'];
         }
         else {
           foreach ($errors as $error) {

In ajax_views.js:

diff --git a/public_html/sites/all/modules/views/js/ajax_view.js b/public_html/sites/all/modules/views/js/a
index acee786..c97abb8 100644
--- a/public_html/sites/all/modules/views/js/ajax_view.js
+++ b/public_html/sites/all/modules/views/js/ajax_view.js
@@ -34,6 +34,25 @@ Drupal.Views.Ajax.ajaxViewResponse = function(target, response) {
     // Show any messages (but first remove old ones, if there are any).
     $view.find('.views-messages').remove().end().prepend(response.messages);
   }
+  if (response.settings)
+  {
+       var i = 0;
+       var gmap = {};
+
+       for (i = 0; i < response.settings.length; i++)
+               if ( typeof(response.settings[i]['gmap']) == 'object')
+                       gmap = response.settings[i]['gmap'];
+                               
+       $view.find('.gmap-map').each(function() {
+                        var id='#' + $(this).attr("id");
+                       var t=id.split('-');
+                       var mapid = t[1];
+                       Drupal.gmap.unloadMap(mapid);
+                       if (gmap && gmap[mapid])
+                               Drupal.settings.gmap[mapid]=gmap[mapid];
+                       $(id).empty().each(Drupal.gmap.setup);
+       });
+  }
 };
 
 /**

The idea is quite easy:

The map is not updated as the gmap is no longer sending its code via

command, but instead adds it directly to the header. But that means that the net markers data is only available in Drupal.settings.gmap, which is not transmitted. So I extend the object to a settings field, to transmit the settings over the network. I then extend the ajax_views.js, in the Drupal.Views.Ajax.ajaxViewResponse function to update the GMAPs using some variant of the code posted here and in another thread. Now comes the clou, we can add this to a custom module, lets call it gmap_ajax: It would work as follows (I hope I have time to actually implement / test that later on): Instead of hacking the code in views, we can add the setting information via the hook_ajax_data:
function hook_ajax_data($object, $views, $view)
{
       // Save settings
       $js = drupal_add_js(NULL,NULL, 'header');
       $object->settings=$js['setting'];

       // Register custom callback
       $object->__callbacks = array_merge($object->__callbacks, array('Drupal.GMAP.Ajax.ajaxFixMaps'));

}
The we can add our custom Javascript code to some additional Javascript file and now we just need to make sure its loaded by adding the code via some drupal_add_js magic. Anyone got an idea where we could best hook into to add the JS only if we are in a view with a gmap? Here is the JS file:
Drupal.GMAP.Ajax = Drupal.GMAP.Ajax || {};

/**
 * An ajax responder that accepts a packet of JSON data and acts appropriately.
 *
 * The following fields control behavior.
 * - 'display': Display the associated data in the view area.
 */
Drupal.GMAP.Ajax.ajaxFixMaps = function(target, response) {
{
  var $view = $(target);

if (response.settings)
  {
        var i = 0;
        var gmap = {};

        for (i = 0; i < response.settings.length; i++)
                if ( typeof(response.settings[i]['gmap']) == 'object')
                        gmap = response.settings[i]['gmap'];

        $view.find('.gmap-map').each(function() {
                        var id='#' + $(this).attr("id");
                        var t=id.split('-');
                        var mapid = t[1];
                        Drupal.gmap.unloadMap(mapid);
                        if (gmap && gmap[mapid])
                                Drupal.settings.gmap[mapid]=gmap[mapid];
                        $(id).empty().each(Drupal.gmap.setup);
        });
  }
}
The above code is for discussion for now. Open tasks: Find a way how to re-initialize a map with markers that first had no markers. Workaround: Even add a small cross marker to an empty gmap. However besides that it works really fine. :-) Comments welcome, Best Wishes, Fabian (LionsAd)
greenbeans’s picture

@Fabian: will you marry me?

Anyone got an idea where we could best hook into to add the JS only if we are in a view with a gmap?

gmap.views.inc calls template_preprocess_gmap_view_gmap()... so maybe in a preprocess hook? I think newModuleName_preprocess_gmap_views_gmap() could work.

Nigel Cunningham’s picture

FileSize
1.64 KB

Subscribing.

Here's a patch implementing FabianX's changes from #81. I'm getting empty marker popups though, so might come back soon with a more complete patch.

(Views 6.x-2.10, Gmap dev from 2010-Apr-09).

Regards,

Nigel

Fabianx’s picture

Hi Nigel,

Thanks for the patch ;-).

For me the marker popups do work. However I had the same problem with wrong marker popups once after upgrading some other system. *sigh*

I installed a clean drupal 6.16, added location-6.x-3.1-RC1, views-6.x-2.10 and gmap-6.x-1.x-dev from 2010-Apr-09.

Then I patched views with the patch and it did work very well for me.

No problem with empty marker popups.

Best Wishes,

Fabian (LionsAd)

Nigel Cunningham’s picture

Hi.

Sorry for not following up on my previous post.

Everything did work - I was just confusing my live site and the test version on my laptop for a bit there.

Thanks for your work!

Nigel

Nigel Cunningham’s picture

Oh, and a link to the live site with working Ajax updates:

http://www.crca.org.au/AboutUs/WhoWeAre/Locations

marcushenningsen’s picture

Status: Needs work » Reviewed & tested by the community

Beautiful, this works! Thanks a lot.

I'm changing status, don't know if it's appropriate, and I don't know if this issue should have its project changed since we are now patching views.

Marcus

jdidelet’s picture

Hi,

Sorry but I tried the patch and it didn't work. Perhaps it's me. I have Drupal 6.16, Views 2.10, Gmap 6.x-1.x-dev (9 April) and Location 6.x-3.x-dev (20 April). If I understood well, the patch modify only views/includes/ajax.inc and ajax_views.js file no? Perhaps I miss something.

I'll try with the new version of GMap, Location (of 29 April) and the last version of Views (30 April). I'll give you my feedback soon.

vangorra’s picture

This is fan friggin tastic!
I've patched my source and its working without any issues. When can we see this patch included into views?

vangorra’s picture

Fabianx

This fix is important to the community and should be included as a patch some place. At the very least (in the meantime) be turned into a module. Since you mentioned that you are short on time, I have created a module form of your patch. I intend to give you FULL credit for the solution and look forward to your collaboration in the future.

This module needs review and is awaiting CVS account approval. It can be viewed here:
http://drupal.org/node/804580#comment-2992150

Nigel Cunningham’s picture

Project: GMap Module » Views (for Drupal 7)
Version: 6.x-1.x-dev » 6.x-2.10

Changing project to views, since that's what we ended up patching.

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

You cannot mean this as reviewed, its perhaps tested but sorry let's have a look at the patch:

diff -ruN .views-unpatched/js/ajax_view.js views/js/ajax_view.js
--- .views-unpatched/js/ajax_view.js	2010-04-10 13:16:25.000000000 +1000
+++ views/js/ajax_view.js	2010-04-17 15:33:12.000000000 +1000
@@ -34,6 +34,25 @@
     // Show any messages (but first remove old ones, if there are any).
     $view.find('.views-messages').remove().end().prepend(response.messages);
   }
+  if (response.settings)
+  {
+       var i = 0;
+       var gmap = {};
+
+       for (i = 0; i < response.settings.length; i++)
+               if ( typeof(response.settings[i]['gmap']) == 'object')
+                       gmap = response.settings[i]['gmap'];
+                              
+       $view.find('.gmap-map').each(function() {
+                        var id='#' + $(this).attr("id");
+                       var t=id.split('-');
+                       var mapid = t[1];
+                       Drupal.gmap.unloadMap(mapid);
+                       if (gmap && gmap[mapid])
+                               Drupal.settings.gmap[mapid]=gmap[mapid];
+                       $(id).empty().each(Drupal.gmap.setup);
+       });
+  }
 };
 
 /**

You should not make extra javascript in the base javascript of views. At least this part has to be fixed in the gmap module.

merlinofchaos’s picture

Status: Needs work » Closed (won't fix)

I'm sorry, I am absolutely not committing GMap specific code to Views. That is 100% against policy.

Nigel Cunningham’s picture

Project: Views (for Drupal 7) » GMap Module
Version: 6.x-2.10 » 6.x-1.x-dev
Status: Closed (won't fix) » Needs work

Sorry, MerlinOfChaos, you're absolutely right.

The fix might work perfectly, but that doesn't mean it right. Please accept my apologies for not looking at it again before making the suggested project change.

We need to fix this properly. Switching back to gmap.

Nigel

Fabianx’s picture

Hi all,

Sorry for the confusion my patch really was only for proof-of-concept purposes.

There is now a custom module for that (as shown above):

http://drupal.org/node/804580#comment-2992150

Thank you vangorra for making a module out of my code! Great solution!

So the BEST solution for this issue for now is:

- Download Tarball from above
- Unpack Tarball
- Enable Module

Perhaps we can now patch gmap (not views!) properly using the code in the module as base.

Best Wishes,

Fabian (LionsAd)

Pix_’s picture

I tried to enable the custom module at #95. It solves the "Javascript is required" issue but no markers are visible after the filter is applied.
Using
- Views 6.x-2.10
- Gmap 6.x-1.1-rc1
- Location 6.x-3.1-rc1

Thanks for the effort you guys are putting into this issue.

edit: just to point that firebug is not showing any kind of javascript error after the filter is applied. The map refresh and show up correctly but without any markers. Re-applying or removing the filter just gives back an empty map

Fabianx’s picture

This is due to the issue that this module still has that there need to be markers from start on. See my original post.

This can be easily workarounded by putting a GMAP as empty text with just one marker.

(Create a macro via GMAP macro creation, then add a filter type which is parsed by GMAP, then add this as empty text with the input type set to your new input type).

Or just use the following PHP Code as empty text and set the id in your gmap settings and below as :

for example: mygmap-id

<?
echo theme('gmap', array('#settings' => array ( 'id' => '<your custom id>', 'markers' => array (0 => array ( 'latitude' => 38.90278963537611, 'longitude' => -77.03338623046875, 'markername' => 'vertex', 'offset' => 0, 'text' => 'Please enter some search terms.')))));
?>
Macro: [gmap id=<your custom id>]

Best Wishes,

Fabian (LionsAd)

Pix_’s picture

I'm sorry Fabianx but i'm missing something obviously.

I tried to make a page-display view, style gmap, with a taxonomy filter exposed. I'm starting with a map that shows all my results. Whithout your module enabled if i try to apply the filter, "Javascript is required..." pops up. Ok.
Enabling your module solve this but gives me back an empty map.
To avoid that, as you suggest, i tried to paste that php code inside the empty text space in my page-display views. The result is the same empty map.
I tried also pasting inside the empty text area this macro i created

[gmap markers=small red::42.17154633452751,12.3321533203125 |zoom=9 |center=42.11656135038903,12.65625 |width=696px |height=400px |control=Small |type=Hybrid]

with a new "GMAP" input type and "GMap macro expander" filter enabled. Im having the same empty map back...

Is there maybe something wrong with my macro?

Bartezz’s picture

At #97, did you see this: http://drupal.org/node/315236#comment-2000766

Cheers

Pix_’s picture

Yes i saw that but i dont start with an empty map. i see gmap_markers.js and markerloader_static.js loaded into head....

Pix_’s picture

I decided to start from scratch again
Looks like i didnt need #95 module at all. Everything is working fine by just applying #40 (fix 1)
i will further test to see if there is something wrong but now eveything looks fine. The filter are applied correctly (taxonomy and node title) and the map refresh using ajax...

mindbat’s picture

Version: 6.x-1.x-dev » 6.x-1.1-rc1

I'm using Views 6.x-2.10 and GMap 6.x-1.1-rc1. After I apply the patch in #40, submitting the filters works (thanks, PaulHruska!) but only the first time I submit the filters. When I try to filter the map a second time, I get the "Javascript is required to view this map" error.

Does anyone have a fix for this bug that doesn't require patching the Views module?

Fabianx’s picture

Small fix for the module:

diff --git a/sites/all/modules/custom/gmap_views_ajax/gmap_views_ajax.js b/sites/all/modules/custom/gmap_views_ajax/gmap_views_ajax.js
index 2828549..eff16d8 100644
--- a/sites/all/modules/custom/gmap_views_ajax/gmap_views_ajax.js
+++ b/sites/all/modules/custom/gmap_views_ajax/gmap_views_ajax.js
@@ -1,4 +1,7 @@
 $(document).ready(function() {
+    if (typeof(Drupal) != 'object' || typeof(Drupal.gmap) != 'object')
+       return;
+
     Drupal.gmap.Ajax = Drupal.gmap.Ajax || {};
     
     /**

else it'll break on views when there is no gmap.

I think module works best with the -dev versions.

Best Wishes,

Fabian

jcmarco’s picture

Version: 6.x-1.1-rc1 » 6.x-1.x-dev
Status: Needs work » Needs review
FileSize
2.41 KB

I have integrated the existing patch with the gmap module, and added some code style cleanup.
Now only load the js file and the callback if the view is a gmap style and has ajax active, this way
we avoid conflicts and extra code in the rest of views.

This patch allows gmap views with exposed filters to AJAX update the gmap view (with even attached tables). You just need to activate the Use AJAX in the view settings.

Thanks to @fabianx for this patch

sreynen’s picture

Status: Needs review » Needs work

When using a display based on the default, $view->display_handler->options['style_plugin'] is not set, so the JS doesn't get added. I worked around this by overriding the default on the display handler and everything worked great after that.

jcmarco’s picture

Status: Needs work » Needs review

I have tested it with a default display (using the preview from the views UI and creating a quicktab with a default view) and I get that style plugin variable always.
Test it yourselft adding after the function definition, a dpm and you will see that variable.

function gmap_views_pre_view(&$view, $display_id, &$view_args) {
dpm($view->display_handler->options);

Please test it again a give us more accurate information to reproduce the problem.

BTW, if you are using a quictab or loading the map in AJAX, then if you get the error that you need the javascript is because the gmap javascript hasen't been loaded before.
But if you check with firebug the DOM you will see that the js with the ajaxFixMap function exists and it should be executed by the ajax view functions.

sreynen’s picture

Status: Needs review » Needs work

@jcmarco, that's exactly what I did, dpm($view->display_handler->options), and there's no ['style_plugin'] value there. There is, instead, a ['defaults']['style_plugin'] set to TRUE, suggesting the value should be pulled from the default display, which makes sense to me (DRY). Steps to reproduce (which I think you misread last time as actually viewing the default display):

1) Create a view with default display style set to "gmap"
2) Create a 2nd display, using the default display's style with no override
3) Turn AJAX on that second display, with exposed filters
4) View that second display and try to update the filters with AJAX

Result: error.

Changing step 2 to override (but still keeping the "gmap" style) makes the ['style_plugin'] value show up, because that gives the 2nd display it's own distinct style_plugin value rather than referencing the default display's. It looks like maybe you need to pull the default display style from $view->display['default'] when another display is using the default.

jcmarco’s picture

Status: Needs work » Needs review
FileSize
2.4 KB

Thank you sreynen, for your review and explanation now I catch the problem.
You are right. The problem with the pre_view hook is that there is no information about the display to show only about the whole view.
So I swap to the pre_render where only the display to show is executed and I do the same, checking that js is only loaded once.

Test it again.

jcmarco’s picture

FileSize
2.38 KB

I forgot a debugging line in the last patch , please use this one.

jcmarco’s picture

FileSize
2.37 KB

I found some js domain definition conflicts. (with IE there were problems loading the rest of javascript and in firebug you have an error)
Instead extending drupal.gmap (that sometimes is not defined) I create this time its own js domain.

EvanDonovan’s picture

Subscribing to come back to later.

Could this solution be generalized further, or would that be out of scope? I just ran into the same issue when loading Gmaps in a Quicktabs block.

I will try to test this patch if someone outlines the steps involved in a successful test.

jcmarco’s picture

The problem with reloading gmap when using quicktabs or jquery tabs is rather different to this issue.
I solved it adding my own js script that reload the gmap when the new tab is shown,
and it will depend of js events from quicktabs or jquery ui tabs that your bind with the gmap refresh action.

To test this patch:

- create a new view with a gmap style display ,
- add some fields to show location of nodes/users
- set Use Ajax
- Add a filter and expose it.

Now you have a gmap with different nodes, and when you change the exposed filter
if you don't have the patch, all the page is reloaded, with the patch only the gmap is reloaded in ajax,
even if you have attached views to the same display all the attachments are updated together. I use it
to show nodes by postal code with a list of sites. If you change the Postal Code and distance then you
have gmap with the nodes on this area and a list of items on this area.

marcushenningsen’s picture

I've tried to apply your patch, but I don't see any change. It's possible that I've misunderstood something.

My use case is this: A view with a table of nodes + an attachment with gmap + a number of exposed filters. On page load the table and the map is shown, but when applying a filter the table is updated but I get the "Javascript is required to view this map" message.

Am I doing something wrong, overlooking something? Do you need some extra info?

Marcus

jcmarco’s picture

@marcushenningsen Did you set the Use AJAX in all your displays?

marcushenningsen’s picture

@jcmarco Yes. Should it work with gmap in an attachment?

frankspin’s picture

I still have this problem. I use the gmap_ajax_views_4.patch .

In firefox everything is working fine, but in safari i get the message: "Javascript is required to view this map."

jcmarco’s picture

@frankspin: How is it possible that I have it working with IE7, Firefox 3.6, Safari 5.0 and Chrome 5.0?
If you don't provide more information, I can't do anything.

@marcushenningsen:
I have it working with a display style gmap, even working with a table attached to that display.
If you have as a main display anything else than a gmap display then the ajax callback is not attached.
So create a GMap style view with an attachment as you can swap the visualization order at the end is the same.
And remember to activate the Ajax in both displays, and link the ajax and the exposed form to the attachment.
To have the ajax working is needed to attach a js callback to the function that have been loaded in the
gmap_views_ajax.js and that only happen with gmap style displays with the ajax on views.

marcushenningsen’s picture

Thanks for the help, it works with the table attached to the gmap instead of the other way around.

jdidelet’s picture

I tried in the both (gmap in attachment of my table display or table in attachment of my gmap display) and it didn't work. With the last version of gmap (of 11 july 2010) and with Ajax enable on the both views... And with the patch 4 (clear all caches of course). ??? Don't really understand.

yannickoo’s picture

I've table display in my attachment and gmap is default. and the path doesn't seem to work ;(

What can I do now?

yannickoo’s picture

Oh you've to pay money for see the install instruductions: http://shop.drupella.com/

I bought it for $12 and I'll get a new module, it's called ajax_gmap.

Hold on ;)

dawehner’s picture

Status: Fixed » Needs review

@yan_nick

The module itself is under the GPL, so you have the freedom to publish it here.
The rest of the module might be under a different license which is not allowed to publish here

yannickoo’s picture

Yes it's under the GPL and will publish it here.

yannickoo’s picture

Hey guys, I bought it 2 times but PayPal can't get my money. It's very bizarre.

Can you try to buy the ajax_gmap?

khosman’s picture

subscribing

Anonymous’s picture

*Sorry if this sounds muddled. Been a long day (elections in Kenya) and I am worn out but if I don't post it now, I will forget by the time I wake up*
I don't know if this helps you guys but throwing it in cause it helped me.

Modules in use. All Version 6 stable releases, but this might be irrelevant cause I sort of reproduced it across different versions (mixes) except a Vanilla build..

CCK
GMAP
Panels
Views

My plan was to be able to have a node with CCK fields and the CCK fields would appear in the marker bubble thingy. I am even able to execute html quite well. However, last night, one of my editors put up some content and it occurred to me that one of the non alphanumeric characters in any of the CCK fields would cause it to trip. I suspect node title or a text field (both html and non-html). I am yet to figure out which character tripped it cause she used just about every character but the maps would not load. After filtering out nodes with special characters it started running again. I went through each and every node (and they were many) and the only thing that caught my eye was that in Node Title there were non-alphanumeric characters. All the other fields were working just fine. They were too many to change, hence I filtered out the ones with the characters and voila.

Just an FYI: Oh, and there is a funny bug with views/Gmap that fails to recognise if a node is published or not. It publishes everything. On my live, the Publish Node filter was not working. This is important if you are experiencing the problem I had and unpublishing is one of your resolution. My solution was to simply filter out by Post Date. Yet to determine if the bug is views, or gmap and yet to reproduce in Vanilla so this is just a FYI.

Hope it helps.

Later boys and girls.

Kahenya

yannickoo’s picture

Hey guys,

I can't order the ajax_gmap module. PayPal doesn't like me ;(

yannnick

tharin2002’s picture

subscribing

SocialNicheGuru’s picture

I had a specific issue of errors when I had a gmap in a panel page. It ended up being a javascript error caused by ctools.

the solution for me is here: http://drupal.org/node/888254

yannickoo’s picture

Status: Needs review » Fixed
jcmarco’s picture

Why do you set this as fixed?
You solved your problem with your third party module,
but not with the ajax views issue, we are trying to add ajax views to the gmap module and not "buy" a module.

Bartezz’s picture

Version: 6.x-1.x-dev » 6.x-1.1

Today I updated views, location and the gmap module to the latest releases and unfortunately everything stopped working. Looking into the gmap module files I noticed that the patches in #41 and #47 never made it in. That sucks to be completely honest! People worked hard on those, other people tested them and then they're not making it into the module :(

Does anyone have a working site with the 6.x-1.1 module version updating via AJAX and Views (6.x-2.7 or higher)?

Cheers

sreynen’s picture

People worked hard on those, other people tested them and then they're not making it into the module

That implies the testing was successful, but it wasn't. According to #65 and #70, those patches don't work on the current dev version.

Bartezz’s picture

@sreynen

They did work for the current version at that time

#65
has become
drupal_add_js(array('gmap' => array($element['#map'] => $map)), 'setting');

That implies that the dev has been updated without applying the patches. Somewhere along the line the JS changed to drupal_add_js while before this was returned as inline code in $o. Also look at the comment #67 in reply to #65 and the ones above stating that is does work. In fact it works so well I have a live site with over 6.000 daily visitors working with the patches in #41 and #47 running since December of last year without problems! -> http://www.zoetermeergezond.nl

Cheers

vishun’s picture

#110 works beautifully...

jcmarco++

joelstein’s picture

Status: Needs review » Reviewed & tested by the community

#110 works great for me, too.

sreynen’s picture

@Bartezz It looks like dev was updated several months ago, when the status was still "needs review." It's a pretty common situation for a patch in "needs review" status to be made invalid by unrelated changes in dev. Sometimes that even happens to patches in RTBC status.

Often in this situation, the patch is updated to work with the new changes. That's exactly what was suggested in #67, "Seems like we just need an updated patch to take into account the changes in the current dev version." Unfortunately no one actually did that, so the patch died. Next time, if you really want to see your patch get committed, you should follow it through the whole process. It's great that you got the problem solved on your own site, but that's not generally the end of the process for getting code committed.

If that's as far as you care to go, that's still really helpful. I just hope you won't be surprised when the same thing happens again, as it's pretty much how contributing works on Drupal.org in general.

jcmarco’s picture

Version: 6.x-1.1 » 6.x-1.x-dev

I have checked the #110 patch with last day committed changes and it is still valid.

I agree with sreynen, I have been releasing patches for this issue fixing any issue commented for the few people that have tested it.
It seems that most of the times the people only remember checking the issue queue and help with patches when they have to present a
project or get paid for some work.

That is about community and not about free riders.

By the way patches are always for the last dev release.

Bartezz’s picture

@sreyen: As far as I can remember the patches I provided were against latest dev at the time though, not 100% sure

@jcmarco: I know what you are saying, but there's only so much time I can stick in the issues I'm involved in. Not sure who your comments were aimed at but I have been checking back and replying since I released that website in dec of last year. But if I recall correctly there wasn't much activity on the maintainer's side. Leaving me thinking my efforts were in vain so I stopped working on it actively. Good to see you've picked up on where some of us left of. I will try your patches asap but am over my head in different projects so it's not likely I will be able to provide feedback soon, sorry.

Cheers

rooby’s picture

Title: GMap View, 2 Exposed Filters and the error "Javascript is required to view this map" upon AJAX update » GMap View, Exposed Filters and the error "Javascript is required to view this map" upon AJAX update

- Changing the title because it also happens with other amounts of exposed filters.

Note: I'm reviewing the patch in #110.

Looks pretty good and fixes the problem for me too.

However I have one question, primarily aimed at merlinofchaos or dereine if hopefully they are still monitoring this issue at all.

+++ gmap.module
@@ -1263,3 +1263,35 @@ function gmap_views_plugins() {
+/**
+ * Implementation of hook_ajax_data_alter().
+ */
+function gmap_ajax_data_alter(&$object, $views, &$view) {
+  // add js callback only with gmap style plugins and with ajax
+  if ($view->plugin_name != 'gmap' || !$view->use_ajax) {
+    return;
+  }
+
+  // Save settings
+  $js = drupal_add_js(NULL,NULL, 'header');
+  $object->settings=$js['setting'];
+
+  // Register custom callback
+  $object->__callbacks = array_merge($object->__callbacks, array('Drupal.gmapAjax.ajaxFixMaps'));
+}

In this part, where we have to add the js settings back in, shouldn't this be done in views because it is something that affects other modules that want to use their own js along side views ajax, not just gmap?
When using ajax, views should load everything in as drupal normally does right?

I have seen a few other modules that have js that breaks when using views with ajax turned on.

Also, the second parameter $views is a bit confusing as it isn't actual views but the text 'views' that gets passed in.
I couldn't find any doco on that hook but at a guess I would think it refers to the module doing the calling and might be better called $module or something? Although I might be way off.

Powered by Dreditor.

morbiD’s picture

The patch in #110 works nicely for me too. I've tried it with 6.x-1.1 and 6.x-1.x-dev and have seen no issues so far.

bdragon’s picture

Assigned: Unassigned » rooby

@rooby:

I have no complaints about the ajax_data_alter implementation.

I'm fine with this patch going in if it seems to work properly, as it doesn't touch any of the really fiddly bits in gmap, so is relatively low impact.

stinsoninc’s picture

Hello,

I am a relative newbie, so sorry if I don't follow certain conventions.

I have been following this thread with great interest because this is exactly what I'm trying to do.

I applied patch #110 I got , but now getting the following error:

"warning: Parameter 3 to gmap_ajax_data_alter() expected to be a reference, value given in /Applications/MAMP/htdocs/drupal-6.19/includes/common.inc on line 2883."

I'm running core 6.19 and gmap 6.x-1.x-dev.

Do I need to upgrade or patch my core also?

Thank you

morbiD’s picture

I actually got the same error message as #144 when I tried the patch on a local copy of a site, but when I patched the live site it worked fine, so I assumed my local copy was just borked from other things I'd been testing.

It's currently working great for me on the live site, but if someone else has seen that error it makes me wonder what caused it.

stinsoninc’s picture

Thanks morbiD for confirming that I'm not going crazy.

There must be something about your (and my) localhost environment. I can't imagine that it's just because it's on localhost, but it probably has something to do with the particular combination of module versions that are causing the patch to either work or not.

On my localhost I'm running:
gmap 6.x-1.x-dev
location 6.x-3.1
views 6.x-3.x-dev

I suspect that views 6.x-3.x-dev may be the culprit. I am going to (with much effort) revert back to views 6.x.2.11 and see if that works.

Do you have any insight on this version idea? Are you running different module versions on your 2 environments?

Cheers

morbiD’s picture

This is definitely some sort of problem with our localhost config. I have just moved a full backup of my working live site into my local server and it immediately produced the error. I'm running Views 6.x-2.11.

What about a PHP version issue? My live site is on PHP 5.2.10 while my local server is on 5.3.3, and doing some googling around Drupal and PHP 5.3, I see other modules have had similar issues regarding passing-by-reference.

rooby’s picture

@bdragon,

No worries, I'll investigate the issues in #144 - #147and then go ahead with the patch as it works for my testing and is definitely needed.
I'll look at it tonight.

I might see about making a views issue at some point to see if at least some of this issue is fixable at the views level.

rooby’s picture

Status: Reviewed & tested by the community » Fixed

Committed with some minor coding standards fixes.

I also fixed the php 5.3 problem reported in #144

http://drupal.org/cvs?commit=446316

Fabianx’s picture

This rocks! Thanks for applying!

Best Wishes,

Fabian (LionsAd)

griff4405’s picture

First, great module, i have been using it for awhile.
I'm still getting the "Javascript is required to view this map."

simple map. just a macro pasted in the body.

-new install of Drupal 6.19
-gmap-6.x-1.x-dev
-php 5.2.14
-jQuery UI 1.6
-views-6.x-2.11

I do not have the location module installed.

Thank you

yannickoo’s picture

Load your scripts in the header, not in the footer (see page.tpl.php)

Yannick

griff4405’s picture

Yannick thanks for the reply.
I looked at my page.tpl.php and my print $scripts;
is in the head.
still no map display. just getting Javascript is required to view this map.

Status: Fixed » Closed (fixed)

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

Alex Andrascu’s picture

Component: User interface » Code
Priority: Normal » Major
Status: Closed (fixed) » Active

I was getting this issue also with jQuery 1.3.2 (manually updated) / jQuery UI 1.7.x
Found out that in my case it was Better Select 6.x-1.0-beta2 causing it.

Caught this under firebug console

Uncaught Syntax error, unrecognized expression: [@type="checkbox"]
F.filter jquery.js:19
F jquery.js:19
F jquery.js:19
o.fn.o.find jquery.js:12
o.fn.o.init jquery.js:12
o.l.jQuery.l.$ jquery.js:12
Drupal.behaviors.initBetterSelect betterselect.js:4
(anonymous function) drupal.js:41
o.extend.each jquery.js:12
Drupal.attachBehaviors drupal.js:40
Drupal.theme.placeholder drupal.js:271
o.extend.ready.o.readyList jquery.js:19
o.extend.each jquery.js:12
o.extend.ready jquery.js:19
o.each.o.fn jquery.js:19

Disabled BetterSelect and i got gmap back
Hope it helps someone.
Alex

Alex Andrascu’s picture

Priority: Major » Normal
Status: Active » Closed (fixed)

setting back the switches...my mistake.

mchoffa’s picture

module fix in #90 worked like a charm. Gmap 6.x-1.1, Views 6.x-2.12, using a gmap page view with exposed filters and a list view attachment

youngelpaso’s picture

#110 patched work great for me so far. Thanks again! Having AJAX is pretty much key to my whole mapping application! Cheers!

donquixote’s picture

Any chance for a new release with this commit included?

carole’s picture

Subscribe

nedjo’s picture

Status: Closed (fixed) » Patch (to be ported)

This error shows up in the Drupal 7 version of the module. It looks like the patch was applied to D6 but not to D7.

nedjo’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
alejandrovk’s picture

'm having the same issue, some debugging leads me to this message:

Uncaught exception: TypeError: '$.cookie' is not a function

Error thrown at line 167, column 2 in ()

Anyone had the same issues?

Regards,
Alex

dgastudio’s picture

subscribing for d7 port of the patch/module

alejandrovk’s picture

Where do I suscribe for that kervi??

dgastudio’s picture

sorry, my fault. I mean "subscribing".

dafeder’s picture

Trying to get this working as well...

dafeder’s picture

Now that there is an AJAX alter function in views again, we should be able to do something here. See http://drupal.org/node/1220498

Itmman’s picture

I had this problem, founding no solution.Then, without any reason it has became to work.
Today the same problem "Javascript required.."

I see that this problem appears when I'm offline, when a connect to internet the map works.

HAve you seen that the problem disapper when you are online and it appears offline?

SocialNicheGuru’s picture

@169 yes.

when I was not connected to the internet, my page took a long time to load, then I got the javascript error.

nkschaefer’s picture

Status: Patch (to be ported) » Needs review
FileSize
2.64 KB

Patch attached for GMap 7.x-dev. Note that, because hook_views_ajax_data_alter() was originally removed from the Drupal 7 version of Views, this patch requires that you are using the 7.x-dev version of Views, not the older one.

I based my patch on the one in #110 - but I tried to sort-of use the Drupal 7 AJAX "command" API in mine. Unfortunately, none of the existing commands could handle what needs to be done - so I created a new command - Drupal.ajax.prototype.commands.gmapAjaxViewsFix - that does the work.

Thanks,
Nathan

nkschaefer’s picture

Agh. Minor change - forgot to acknowledge that, in the D7 version of GMap, the Views plugin name can be either 'gmap' or 'gmapextended' - changed the if statement on line 1323. Please use this patch instead.

stopshinal’s picture

Assigned: rooby » stopshinal

subscribing

dgastudio’s picture

i have applied patch from #172 to the last dev.

but still with the error "Javascript is required to view this map."

example: http://dev.yogalife.by/gmap

nkschaefer’s picture

I just looked at your page - for one, when I click "Apply," the page is refreshing - so it's not using AJAX to reload the map. Maybe you need to set a permission so anonymous users can test that out using AJAX?

Second, I looked at the Javascript files on that page - and the file "gmap_views_ajax.js" wasn't one of them. Can you look in the module's directory to make sure that file was added? It should be in gmap/js/gmap_views_ajax.js. If that file doesn't exist, then you may not have applied the patch correctly - that's the file that does the work.

Thanks,
Nathan

dgastudio’s picture

yes, u are right, i have disabled ajax funcionality for test.

now i'm testing again and as u say, gmap_views_ajax.js is not found. so i recheck the patch and i have found the problem.

look, my steps to apply the patch:

ssh
wget http://drupal.org/files/issues/gmap_ajax_views_d7_172.patch
patch < gmap_ajax_views_d7_172.patch

the patch is applied correctly but the file gmap_views_ajax.js was created in /sites/all/modules/gmap folder and not in sites/all/modules/gmap/js as is must be.

i have movied the file to correct folder and now everthing seems working fine.

thank u and sorry for my english.

dgastudio’s picture

and, after apply the patch and submit the views form,the options in exposed filter are changed to 1,1,1,1:

open, http://dev.yogalife.by/gmap
click apply.

as i can see, this bug is produced by js.

scotwith1t’s picture

In case someone stumbles upon this as I did, I used the module file @ #90 (for D6 gmap) and my superfish menus were broken from then on (not rendering sfHover class, but #103 fixed that. Thanks all!

nkschaefer’s picture

Assigned: stopshinal » Unassigned

Have any other Drupal 7 users gotten a chance to look at the patch in #172? As far as I know, it should work (and put the Javascript file in the right place) if you apply the patch using "git apply."

avner’s picture

i tested it on d7 with no success,
am still getting the same error once applying the filter.
js function is not invoked at all.
started debugging and noticed the gmap_views_ajax_data_alter hook in not invoked as well

when searching for the hook in the views i found several related issues,
and that there was a commit yesterday
i upgraded the views to the latest (dated 2011-Oct-17) and now the ajax works fine!

btw,
the JS file was created in the right location:

patch:67: trailing whitespace.

Checking patch gmap.module...
Checking patch js/gmap_views_ajax.js...
Applied patch gmap.module cleanly.
Applied patch js/gmap_views_ajax.js cleanly.
warning: 1 line adds whitespace errors

thanks!

avner’s picture

Steven.Pescador’s picture

Worked perfect for me using the latest D7 dev versions. Thanks nkschaefer!

firebus’s picture

Here's the patch for rooby's commit in #149 (I need this for a drush makefile, but maybe it will be useful for others too)

brandy.brown’s picture

I applied the patch in #172, but it is still not working with me. My page doesn't reload so I know that it is actually using AJAX. When I look at the source, it is calling the correct js file. Unfortunately I can't link you to my page because it's not available to the public ... any thoughts?

EDIT
-------
I now see that my views isn't working with ajax on anywhere so, I'm going to fix that problem and then come back and try this patch again.

dgastudio’s picture

u can check http://drupal.org/project/getlocations module.
Some features
- google maps api v3
- ajax working fine

brandy.brown’s picture

Ok I finally fixed my views ajax problem, applied the patch in #172 again and BAM it worked. YAY! Thanks!!

dimon00’s picture

ajax+path=working (I had to disable and re-enable the gmap module).

But on IE9 the map is loaded twice: the first time I see the spain (which disappear immediatly) then the map is reloaded zooming on the right area (where I have my markers).
With chrome and firefox the map is loaded only once: on spain! I don't get the area with my markers. :(

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

As original patch author of this approach, I tested this again briefly with a recent version of Views and it is working fine.

Please use Dev Versions of Views _and_ GMAP, get it working, then you can try a lower version.

Why it is needed:

When a view is reloaded via AJAX, the Map JS settings were not updated.

All this patch does is to add another behavior to the View in question to save the JS code (this was btw. the standard for other AHAH modules) and transfer this JS code together with the updated view to the client via AJAX.

The View is also changed to call another function after the AJAX has been received. The settings are updated and the maps that are affected reloaded.

Please apply.

Best Wishes,

Fabian

olofbokedal’s picture

Status: Reviewed & tested by the community » Needs work

This isn't working for me. I'm using the latest dev versions of GMap and Views, and applied the patch at #172. I've verified that the new JS file is loaded.

At some point, the map reloaded as it should, but the filter wasn't applied. But now, for some reason, that map disappears.

This is the steps I took.

  1. Upgraded Views from RC3 to dev.
  2. Verified that I had the latest dev of GMap.
  3. Disabled and uninstalled GMap.
  4. Enabled GMap.
brandy.brown’s picture

have you verified that exposed filters is working for you ... in any view?

olofbokedal’s picture

Yes. The exact same view works as intended if I change the display to an unformatted list.

dimon00’s picture

I'm testing with the last views dev version (drupal 7.9).
I applyed the patch to gmap.

The gmap_views_ajax.js is loaded

But still I get:
Javascript is required to view this map.

I'm using gmap extended.

Ideas?

sco_tt’s picture

I was able to make this work in Drupal 7:
I updated Views to dev, disabled GMAP, used the patch in #172, moved the gmap_views_ajax.js to the gmap/js folder, re-enabled gmap and presto.

Unfortunately, I had already put some custom javascript in the header of my page (see http://drupal.org/node/150939) to center the map and autosubmit lat/long values to another an exposed view listing nodes.

The code is:

    jQuery(function($) {
    $.extend({
    initialize: function () {
    var m = Drupal.gmap.getMap('nodemap');
    if (m.map && m.ready) {
    $.setCoords();
    }
    else {
    m.bind('ready', function(data) {
    $.setCoords();
    });
    }
    },
    setCoords: function () {
    navigator.geolocation.getCurrentPosition(function (position) {
    var gmap = Drupal.gmap.getMap('nodemap').map;
    var lat = position.coords.latitude;
    var lng = position.coords.longitude;
    gmap.setCenter(new google.maps.LatLng(lat, lng));
    gmap.setZoom(12);
    document.getElementById('edit-distance-latitude').value=lat
    document.getElementById('edit-distance-longitude').value=lng
    var submitButton = document.getElementById("edit-submit-initiatives-listing");
    submitButton.click();
    });
    }
    });
     
    $.initialize();
     
     
    });

Now, when I load the view initially, the map centers and zooms using the JS above. When use the exposed filters, it correctly filters the nodes on the map, but the map reverts to it's default zoom and center.

I know there's a conflict betwen the code above and the gmap_views_ajax.js file, but I'm not good enought at JS to figure it out. Any clues?

penyaskito’s picture

albech’s picture

Applied the patch, moved the gmap_views_ajax.js to js/, but it appears not to load gmap_views_ajax.js.
AJAX enabled in the view.

Tried with all different formats from 'Unformatted list' to the different GMap formats.

In gmap.module I see:

drupal_add_js(drupal_get_path('module', 'gmap') . '/js/gmap_views_ajax.js', array('group' => JS_DEFAULT));

So I believe it was patched correctly.

Needless to say I am still getting: Javascript is required to view this map.

penyaskito’s picture

berenddeboer’s picture

Same problem here. Applied #172, cleared cache, cleared views cache just to be sure, nothing helped.

Using views 3.1, gmap dev latest.

berenddeboer’s picture

Some more: I'm actually using an attachment to display the map, so the map is not part of the main view. It appears that gmap_views_ajax_data_alter() is only called with a plug_name == "default", so the attachment isn't processed here?

berenddeboer’s picture

Just commenting out these lines in gmap_views_ajax_data_alter() makes it work.

  if (($view->plugin_name != 'gmap' && $view->plugin_name != 'gmapextended') || !$view->use_ajax) {
    return;
  }

I'll roll another patch tomorrow which scans attachments properly.

berenddeboer’s picture

Status: Needs work » Needs review
FileSize
2.91 KB

Here the patch for D7 so gmap ajax updates also work when gmap is an attachment.

berenddeboer’s picture

Oops, left a console.log in my patch, here an attempt to remove that.

Kleve’s picture

The patch does not work for me. Anyone else having problem with it?

Experiencing the same problem as the initial issue, filter gmap view when using AJAX. Using Drupal 7.12 and gmap 7.x-1.0-dev.

For some magic reason the patch started to work after a while and now everything works as it should. You might think clearing the cache made it work, but this time it was not. Maybe some views or settings needed to be updated. Anyway, everything works great now.

Kleve’s picture

Patch doesn´t seem to work in IE.

Anyone experiencing the same problem?

Krents’s picture

Assigned: Unassigned » Krents
Category: bug » task

patch #201 work for me..... Thanks, life saver

Macronomicus’s picture

Wow... #185 was the perfect solution, it works great!
Perhaps http://drupal.org/project/getlocations module is the gmap replacement at this point?

pepon_76-1’s picture

Patch #200 Works for me, :-) Thanks a lot !!!!

haiiro.shimeji’s picture

#200 works for me, but there is a little matter that the center position and zoom is reset after ajax-reloading.
I wonder it is not necessary to re-setup the map after receive the ajax response, but clear markers and draw new ones.

I have a patch this solves the problem.

haiiro.shimeji’s picture

Sorry, I have mistakes to make the patch..

axgalloway’s picture

Tip for everyone just starting to use Gmap and discovering the issue:
-Install Patch
-Clear Cache
-Delete Browsing History and Temporary Internet Files
-Ta-Da!

merch’s picture

Using Patch #208
I have a block display using a table format with a GMAP attachement display using ajax and exposed filters

Before adding the patch:

Exposed filters would effect the table and the map would display the mesage javascript is required to view this map.

After the Patch:

Map works 100% however the exposed filters are not effecting the results of the table view

Really want to get this working

EDIT: Rolled back and tried patch #201 works so far without problems

axgalloway’s picture

Yea, I used #201 too.

haiiro.shimeji’s picture

Status: Needs review » Fixed

Ok, patch #201 is applied to 7.x-1.x branch. Thanks a lot!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

#201 doesn't work for me.

Using 7.x-1.x-dev and have done all the tricks in #209.

I have a block with exposed filters using AJAX. When the page loads the map displays but when you apply a filter you get the "Javascript is required to view this map." error.

S

dharam1987’s picture

Status: Closed (fixed) » Needs work

Hello,

I am still getting the same error, #201 seems to have been applied, but still Javascript not loaded error is coming for me. This is when I am using a exposed filter and having ajax on. Banging my head, anybody found a fix for this, please let us know here.

Thanks

gnal’s picture

Patch #201 wasn't working for me until I updated views to the latest stable release. If running with an outdated rc version of views the patch won't work (because of http://drupal.org/node/1220498 issue).

podarok’s picture

Status: Needs work » Needs review

#208 needs review
Can anyone test it against latest devs
If all ok - I`ll push it with upcoming beta release

podarok’s picture

Status: Needs review » Needs work
+++ b/gmap.moduleundefined
@@ -1310,6 +1310,69 @@ function gmap_views_plugins() {
+  ¶

trailing whitespace

+++ b/gmap.moduleundefined
@@ -1310,6 +1310,69 @@ function gmap_views_plugins() {
+  }
+  ¶

trailing whitespace

+++ b/gmap.moduleundefined
@@ -1310,6 +1310,69 @@ function gmap_views_plugins() {
+function gmap_views_pre_render(&$view) {
+  ¶

trailing whitespace

+++ b/gmap.moduleundefined
@@ -1310,6 +1310,69 @@ function gmap_views_plugins() {
+  drupal_add_js(drupal_get_path('module', 'gmap') . '/js/gmap_views_ajax.js', array('group' => JS_DEFAULT));
+  ¶

trailing whitespace

+++ b/gmap.moduleundefined
@@ -1310,6 +1310,69 @@ function gmap_views_plugins() {
+function gmap_ajax_render_alter(&$command) {
+  ¶

trailing whitespace

+++ b/gmap.moduleundefined
@@ -1310,6 +1310,69 @@ function gmap_views_plugins() {
+  }
+  ¶

trailing whitespace

+++ b/js/gmap_views_ajax.jsundefined
@@ -0,0 +1,24 @@
+(function ($) {
+	
+Drupal.ajax.prototype.commands.gmapClearMarker = function (ajax, response, status) {
+	
+	for ( var i in response.mapid ) {
+		var id = response.mapid[i];
+		delete Drupal.settings.gmap[id].markers;
+	}
+	
+};
+
+Drupal.ajax.prototype.commands.gmapRepaint = function (ajax, response, status) {
+	
+	var mapid = jQuery( response.selector + ' .gmap').attr('id').replace(/gmap-(.*)-gmap./,"$1");
+	
+	var map = Drupal.gmap.getMap( mapid );
+	if ( map ) {
+		map.change('clearmarkers',-1);
+		map.change('iconsready',-1);
+	}
+	

tabs!!
We should use spaces for tabstops

johnv’s picture

Status: Needs work » Fixed

This issue is fixed with #201 and committed as reported by haiiro.shimeji in #212

@haiiro.shimeji, your adapted patch in #208 is not committed. You say

#200 works for me, but there is a little matter that the center position and zoom is reset after ajax-reloading. I wonder it is not necessary to re-setup the map after receive the ajax response, but clear markers and draw new ones. I have a patch this solves the problem.

If still necessary, can you open a new issue with that matter and a new patch?

Thanks!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary.

johnnybgoode’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Issue summary: View changes
Status: Closed (fixed) » Needs review
FileSize
410 bytes

This fix should work for both style plugins provided by Gmap, currently it will only work for the 'gmap' style plugin, not 'gmapextended'. Patch against the latest 2.x-dev is attached.

podarok’s picture

Status: Needs review » Needs work
-  if (!(in_array('gmap', $plugin_styles))) {
+	if (!count(array_intersect(array('gmap','gmapextended'), $plugin_styles))) {

code style error https://drupal.org/coding-standards#indenting

tanmayk’s picture

Patch from #221 worked for me.

Status: Needs work » Needs review
Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBC! - Still following my very first Drupal patch and it still has activity. After 4 years! :-D

Fabianx’s picture

RTBC! - Still following my very first Drupal patch and it still has activity. After 4 years! :-D

yannickoo’s picture

Status: Reviewed & tested by the community » Needs work

Per #222

podarok’s picture

Status: Needs work » Fixed

#221 commited ))))

  • podarok committed 70ba6b4 on 7.x-2.x authored by johnnybgoode
    Issue #315236 by jcmarco, haiiro.shimeji, berenddeboer, nkschaefer,...

Status: Fixed » Closed (fixed)

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