Hi,
I want to center a gmap view on coordinates passed by views arguments arg(1) and arg(2).
So I am trying to apply the php filter to the gmap macro in gmap.module
Around line 347 I change
function gmap_parse_macro($instring, $ver = 2) {
require_once drupal_get_path('module', 'gmap') . '/gmap_parse_macro.inc'; into
function gmap_parse_macro($instring, $ver = 2) {
$instring=check_markup($instring, 3, FALSE);
require_once drupal_get_path('module', 'gmap') . '/gmap_parse_macro.inc'; (without php tags)
And my macro gets to be
echo "[gmap|zoom=4|width=300px|height=200px|center=".arg(1).",".arg(2)."]"; (with php tags)
All that works fine.
But as I have 800 locations I want to filter with the proximity filter, on the proximity.
So in filters I select "Location: Distance / Proximity" and a static latitude and longitude. As values I tried arg(1); and echo arg(1); but none of them work.
I tried to include the php filter in location.views
case 'static':
$coordinates['latitude'] = (float) $options['latitude'];
$coordinates['longitude'] = (float) $options['longitude'];
break;
into
case 'static':
$coordinates['latitude'] = (float) check_markup($options['latitude'], 3, FALSE);
$coordinates['longitude'] = (float) check_markup($options['longitude'], 3, FALSE);
break;
but no avail.... almost there, tips? anyone?
Comments
Comment #1
eiland commentedmy bad, there's just a php filter for proximity, so
its just
change status to needs review because of applying php filter in gmap.module
Comment #2
eiland commentedthe coordinates are of course not passed by arg(1) and arg(2) but by
ill probably set the zoom level too with an argument.
Comment #3
eiland commentedBeware, it is important that the filter format chosen in
$instring=check_markup($instring, 3, FALSE);Where 3 represents the filter item as in /admin/settings/filters, is PHP only, so no GMAP macro filter. That will break the function and show the default map instead.Comment #4
alanpeart commentedYour simple fix here (adding the PHP filter to the GMap macro) just saved my life! I needed to center the map on a postcode argument and this did the trick, thank you.
Comment #5
joomtech commentedcould you please guide me more how to do that? For instant, what should be in the view path such as localhost/testview/10.123123,20.2313 ???
And which module files needed to be modified?
Thank you very much!
Comment #6
eiland commentedHave you tried localhost/testview/10.123123/20.2313
so with a slash between the arguments?
And you only modify the gmap.module file.
Comment #7
joomtech commentedThank you very much for your answer. I have solved the problem already.
Comment #8
landing commentedsub
Comment #9
andrea.cavattoni commentedi 'm doing the same thing but with smart ip, and i cant understand why, but it's not working, i just get an zoom error message in the map.
i'm using this code:
someone can help me?
Comment #10
eiland commentedseems you forgot the dot (.) between center=" and $_SESSION
Comment #11
andrea.cavattoni commentedmmm yep, but still not working:
if i print it with php in the tpl works fine, dont know what's wrong with this code.
Comment #12
agileware commentedChanging status - no patch to review.
Probably should add this to the views style instead of the macro function.
Comment #13
agileware commentedIt also shouldn't rely on the PHP input format.
The number 3 will not always be the PHP filter and the PHP filter module may not be installed.
Comment #14
andrea.cavattoni commentedPhp filter is installed, and the php macro extend too, dont know,
also this one isn't working:
http://envisioninteractive.com/drupal/user-targeted-content-with-drupal-...
Comment #15
andrea.cavattoni commentedHi At list i had to change gmap_parse_macro.inc
Righe : 61->65
if(module_exists('php')) {
$instring = php_eval($instring);
}
Comment #16
dabeer commentedI've managed to apply php filter to gmap by modifying gmap.module.
I'm trying to use php to set zoom in Gmap macro with:
The code works fine, which proves php is working.
However, I would like to apply different zoom for individual nodes. So each node that has a location stores the desired zoom level in an integer field (field_zoom).
I cannot figure out how to retrieve the value of the field_zoom with php so that I can use it in the Gmap macro. I've tried:
but it does not work.
Can anyone point me in the right direction?
Comment #17
podarokright statuses