I am attempting to use the location of each user (by way of the smart ip module) to center the map upon loading. So far it seems to be converting the IP to lat/long and storing them in the variables
$_SESSION['smart_ip']['latitude']
$_SESSION['smart_ip']['longitude']
Is there a way to override the gmap default settings and use these variables if they exist for given user, otherwise use the default settings?
I am currently using the location and view modules, among others.
I appreciate any help that can point me in the right direction.

Comments

asutton’s picture

I am trying to use the following code in the GMap view macro box:

[gmap zoom=3
|center=

 echo $_SESSION['smart_ip']['location']['latitude'].",".
$_SESSION['smart_ip']['location']['longitude']; 

|width=600px
|height=400px |control=Small |type=Map]

PHP filter is enabled in modules.
this macro breaks my map and does not show default settings. any help is appreciated!

asutton’s picture

Status: Active » Fixed

problem solved. the issue was with my filters being out of order.

Status: Fixed » Closed (fixed)

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

andrea.cavattoni’s picture

i cant solve the same problem, can u help me?

mmll’s picture

Version: 6.x-1.1-rc1 » 7.x-1.x-dev
Status: Closed (fixed) » Active

Have been around wondering for quite a bit already how to set lat&long got from user ip for default map.
I'm newby in code but can handle if pointed in concrete direction.

I have Smart IP and PHP filter installed, using D7 though.

This issue is closest I got. #1 didnt work for me.
I played around with it, also tried to paste it into macro to generate node/map to see what happens in. I got error (no map zoom etc).

javi.pl’s picture

Issue summary: View changes
StatusFileSize
new19.92 KB

I had the same problem.
Solution -> add patch (this patch allow to implement php into macro, tested only in views )

Macro example:

[gmap align=Center |zoom=10 |center=

 echo geoip_record_by_name($_SESSION['smart_ip']['location']['ip_address'])['latitude'].",".
geoip_record_by_name($_SESSION['smart_ip']['location']['ip_address'])['longitude']; 

|width=100% |height=600px |control=Small |type=Map]

I had also problem with "Smart_ip" module. If that's a problem check if you have proper $_SESSION['smart_ip'] variable.

dpm($_SESSION['smart_ip']); (you need to have devel module instaled)

javi.pl’s picture

StatusFileSize
new513 bytes