Hi all, thanks for this plugin,
would like to know if possible to add the geolocalisation with eh Google map API ?
thanks for your answer 🙂
the feature is not present, by doesn’t support, do you mean this is not possible to add it, it is not compatible, or you mean it is not in future features ?
thanks for you answer.
I don’t have any plans to add it in the future.
Hi, Ian, thanks for your answer,
Maybe I’ll spend some time to add it and give it to you, can you tell where to dig in your code please?
if you don’t mind ?
I thaught about having a checkbox in the admin side to activate it
to let the posibility to have the markers more LOCAL !
thanks for you anwser
This option would be excellent .. I’d love to be able to use this option.
I’ve tried many ways to put the geolocation and I didn’t succeed.
Hey guys, I have the same question. The way I am approaching it is by using a separate geolocation plug-in, which works well (My Geo Posts Free), which gives you short codes you can work with containing location data for visitors based on their IP address. I was hoping I could pass the short code [mygeo_city] which in my testing properly resolves a valid city name, and pass that in to this plugin. I tried it directly by doing a line like this:
but that didnt work. For me this is more of a general question about the flexibility of the plug-in: is there a way to pass variables to it, for the configurable parameters?
I ended up working this out after some further research and testing; maybe this will help someone else.
First, I needed to load a plugin to allow PHP parsing in the code. Since this is running on my server, I know PHP is already running, and .html is allowed to parse and execute PHP code. This may vary for you if you’re on a hosted service.
I used a PHP plugin called “Insert PHP”. This lets you run normal server-side PHP on your WP site, and instead of opening/closing with “<PHP? ?>” you just open/close with “[INSERT_PHP] [/INSERT_PHP]”
With that taken care of, I turned back to the “MY Geo Posts Free” plugin, to pass the location data to a variable, so I could build the HTML string for “Basic Google Maps Placemarks”. This was easy enough, and the one thing however that took me a little bit to figure out, was that the data from the geo plugin is actually an array value not just a a string. Not realizing this right away meant it kept tripping up the HTML string I was trying to build.
In “My Geo Posts Free”, you can get just the string value from any of the shortcodes, by using
echo do_shortcode('SHORTCODE');in your PHP instead. Once I used that to fill my variable, all was well. My Google map will now center on the city location of the user accessing the site, based on their public IP address.
In the below code, what I am still working through, and would love some feedback, is what happens when the city name is not unique.. for example there are a ton of “springfield” in the USA. I think I would rather handle it by ZIP code, and the geo plugin does have a provision for that, but for some reason I am not getting a 5-digit number back from that, only 3 digits, but that’s for me to work out in a different forum. Here’s my code, I hope this helps someone!
[insert_php] $location = do_shortcode('[mygeo_city]'); echo "<span style='color: #444444;'>[bgmp-map center='" . $location . "'] </span>"; [/insert_php]
EDIT: using lat/long coordinates instead of city, problem solved
I ended up passing the latitude and longitude from the geo plugin, and that seems to be the best method, and should work globally. Here you go:
[insert_php] $latlong = do_shortcode('[mygeo_latitude]') . "," . do_shortcode('[mygeo_longitude]'); echo "<span style='color: #444444;'>[bgmp-map center=".$latlong." zoom=10] </span>"; [/insert_php]
- The topic ‘Geolocalisation ?’ is closed to new replies.