Hi Xmarket,

Thank you again for your wonderfull module. And for your strong reactivity.

Do you think it could be possible to implement such a map ?
http://www.tripadvisor.com/LocalMaps-g298484-d691623-Cafe_Pushkin-Area.html
And how ?

Interesting feature is this search form on right side to interactivly filter markers.

Comments

Sinan Erdem’s picture

Good idea. I tried to achieve this with Views' exposed filters. It works nice if I select "use AJAX" as "NO". But it doesnt work with "use AJAX: YES".

m.sant’s picture

Title: High interactive map implementation » Exposed filter doesn't work with AJAX enabled (was: High interactive map implementation)
Category: support » bug

Same issue for me: I have an exposed filter on a vocabulary, but it only works with AJAX disabled.
AJAX is needed if you use a block display or an attached view.
I changed the category to "bug report", because it has been reported by two users.

Regards,
Marco

mdroste’s picture

Same for me: Exposed filter doesn't work with AJAX

m_z’s picture

I am not sure if I should start a new issue:

If I choose "GMaps Map" as style plugin for a GMaps based View that will return some "Points" (markers) and I activate a Pager AND AJAX,
then clicking the Pager links will result in an AJAX refresh of my Map, but the marker(s) don't change.

The same setting with deactived AJAX option works as expected.

Please tell me, if I should put this "bug" in a new issue.

Thanks in advance,
Martin

xmarket’s picture

Category: bug » feature

In fact, the map is a js object, which needs a container (div) on the HTML level and a set of configuration option whose are stored in the Drupal.settings variable.

The problem coming from the limitations of Drupal's AJAX support, which can't add new properties to the Drupal.settings variable on the current page before the handling of the AJAX response, which, in turn, makes impossible to load a new map in an AJAX request.

These situation can be solved by hacking the AJAX support of Drupal, and sometimes Views, on the client side and the specific page handlers on the server side.

I'm marking this issue as a feature request, because of the above described.

xmarket’s picture

Title: Exposed filter doesn't work with AJAX enabled (was: High interactive map implementation) » Maps can't loaded in AJAX requests
ailgm’s picture

Details on the hacks required would be helpful. This is a significant limitation.

m_z’s picture

@xmarket:

Why do you need Drupal.settings variable? Is it possible to put the new GMarkers (lat, long and all that stuff) in an "old fashioned" XML file(-stream) to make it available for Google Maps JavaScript routines? I am not that deep in this topic, so it is only an idea for a solution without Drupal.settings.

xmarket’s picture

For #7:

Well, On the server side, you should replace all related menu handlers in a hook_menu_alter() implementation and change all calls to drupal_json() to gmaps_ajax_json().
On the client side, you should change all $.ajax() calls to Drupal.gmaps.loadAjaxContent() in all related js files and maybe change the code to be $.ajax() compatible.

xmarket’s picture

Status: Active » Postponed

For #8:

Why do you need Drupal.settings variable?

This variable holds the preset's settings and the actual content, too.

Is it possible to put the new GMarkers (lat, long and all that stuff) in an "old fashioned" XML file(-stream) to make it available for Google Maps JavaScript routines?

This solution is possible, of course, but it is effective only when the content (or the way to generate the content) is known in the time of coding of the XML request handler, which is not true for dynamic, Views-based maps. A better solution would be to load new settings as part of the HTML response. (f.e. prefix it with the required script tags. I'm not sure, but I think, this has been implemented in D7.)

I.m sure, it will be fixed in the D7 branch of gmaps, but there is only a very little chance to implement it in the D6 branch.

m_z’s picture

@xmarket: Thank you very much for your answer.

I have some additional questions which are not urgent:
- Are the preset's settings static when using a pager in a Views-based map (e.g. the GMap size and properties like 'hybrid')? Or do they contain dynamic components, which change while paging through a Views result set (e.g. center, zoom, borders)?
- Do you mean with "actual content" the coordinates and the information which should be placed in the info window when clicking on a marker? Or are there other important "incredients" in the "actual content".

And I don't finally understand the problem with Drupal.settings variable. In my opinion it is a mechanism to put some "settings" from PHP code into JavaScript, isn't it?
An AJAX callback function (like what is processed after clicking a pager link below a Views-based GMap - e.g. give me the next 10 points which match my query) executes PHP and returns its results via JSON to JavaScript, right? Is there any problem to "refresh" all settings ( = preset settings AND actual content) via JSON? In my opinion it doesn't matter for JavaScript if a variable comes via Drupal.settings or via JSON - it must be present and that's enough.

It is difficult for me to explain (maybe a native English speaker could help?) and I am not that deep in GMaps "inner workings", but at the moment I don't see the "big obstacle" to set AJAX-compatibility of GMaps module aside for Drupal 6.
I am sure that there are ways, where you don't have to patch Drupal core and get the wanted result - e.g. to implement GMaps own AJAX-pager for paging through Views result sets (where your callback uses JSON to place everything what is needed for the "next" result page in DOM). When I have more time, I will start exploring the way how the AJAX mode is working in Views module.

@xmarket: I would be glad, if you can support the search for a solution of AJAX-compatibility of GMaps module for Drupal 6 with your deep knowledge about this module. Changing status to "needs work"?

xmarket’s picture

Are the preset's settings static when using a pager...

Everything can change between pages depending on the context. Not typical, but possible.

Do you mean with "actual content" the coordinates...

The actual content means the overlays (markers, polylines, etc) that should be added to a map. An overlay is a set of settings required to build a specific overlay. For more details, please explore the Drupal.settings.gmaps.map object from FireBug on a page that has a map with markers.

And I don't finally understand the problem with Drupal.settings variable. ...

Without details, The problem is that NONE of the existing AJAX solution can refresh the Drupal.settings variable on an AJAX request.

m_z’s picture

@xmarket: Thanks again for your reply.

In the meantime I started exploring the way how GMaps interchanges data between PHP and JavaScript. I will post a patch here, if I found a way to solve this issue for Drupal 6.

Here is my concept:
- you click on a pager link in a GMaps-based View
- the AJAX callback does something like print drupal_json(array('new_lat' => $new_lat, 'new_long' => $new_long));
- via a GMaps JavaScript the JSON properties are catched (jQuery.getJSON) and ...
- ... placed in Drupal.settings variable --> the rest works like "normal" page 1 (or non-AJAX pager) processing
OR
- ... build a switch in "normal" GMaps JavaScript processing which decides if Drupal.settings (default) or "my" JSON properties should be used for GMap generation (This second alternative is needed if xmarket is right with his statement "NONE of the existing AJAX solution can refresh the Drupal.settings variable on an AJAX request", but I will start trying the first option because it requires less changes to the way GMaps generates its maps.)

Sinan Erdem’s picture

Not AJAX but I am at least thinking of a functionality:

A block interacting with the map. A very good example is: http://eat.fi/en/helsinki. On that site, when you hover over a restaurant on the right, it indicates a point on the map.

The example given on the issue by srobert72 (http://www.tripadvisor.com/LocalMaps-g298484-d691623-Cafe_Pushkin-Area.html), can at least be thought without dynamic content but with just hiding some content.

I just experimented a little with Tablo of Content option on map preset settings page. It gives some similar functionality but just in the opposite direction (map affects block). Is it possible to do similar (but block affects map) functionality in a seperate block? Just as we put the exposed filter in a block on Views...

srobert72’s picture

@etcetera9 your example looks very interesting

D.H.’s picture

@market: I tried your advice from #9 to replace the methods with the gmaps ones. I recieved the following error message:

uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://xck.module_test:8082/misc/jquery.js?t :: anonymous :: line 13" data: no]

Can you give some more explanations on the hack your were describing?

I'm using the Drupal.gmaps.loadAjaxContent like:

var ajax = $.ajax({
    type: 'POST',
    url: window.location.href,
    data: "nodes="+arr,
    dataType: 'json',
    success: Drupal.faceted_ajax_search.ajax_to_gmaps_event
  });
  Drupal.gmaps.loadAjaxContent(ajax);

And the gmaps_ajax_json like:

$json = array();
$viewName = 'faceted_gmaps';
$display_id = 'page_1';
$myNodes = explode(',',$_POST['nodes']);
$json['gmaps'] = views_embed_view($viewName, $display_id);
exit(gmaps_ajax_json(array('status' => TRUE, 'data' => $json)));

The "views_embed_views" function doesn't seem to work properly for the gmaps module.

Sinan Erdem’s picture

There is a very nice module for GMap module which allows Ajax pagination or exposed forms: http://shop.drupella.com/product/ajax-gmap

It is not free but maybe it gives an idea...

srobert72’s picture

Very interesting feature.

Google Maps Tools module better than GMap module in my opinion.
With such a feature, Google Maps Tools module would be cream of the cream.