Advertisement:

Author Topic: google maps: show region if the location is not specified  (Read 2604 times)

Gabender

  • Jr. Member
  • **
  • Posts: 53
google maps: show region if the location is not specified
« on: January 31, 2014, 02:30:09 am »
I would like the google map, if the user does not specify the exact location, visit places like the region, which is mandatory in my site so there will always be. how to do?

emuigai

  • Newbie
  • *
  • Posts: 2
Re: google maps: show region if the location is not specified
« Reply #1 on: February 09, 2014, 09:28:03 pm »
I am not sure what you mean by exact location. But I had a close similar problem.
Go to plugins directory and and google maps the map.php you can add something similar
Code: [Select]
if(( $item['s_city_area'] == '' ) && ( $item['s_city_area'] == null )){
            if( ( $item['s_city'] != '' ) && ( $item['s_city'] != null ) ) { $addr[] = $item['s_city']; }
}

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: google maps: show region if the location is not specified
« Reply #2 on: February 10, 2014, 01:13:52 am »
Guys,
If you download latest version of Google Maps Plugin, you can find location "catcher" in map.php file:
Code: [Select]
        <?php
            $addr 
= array();
            if( ( 
$item['s_address'] != '' ) && ( $item['s_address'] != null ) ) { $addr[] = $item['s_address']; }
            if( ( 
$item['s_city'] != '' ) && ( $item['s_city'] != null ) ) { $addr[] = $item['s_city']; }
            if( ( 
$item['s_zip'] != '' ) && ( $item['s_zip'] != null ) ) { $addr[] = $item['s_zip']; }
            if( ( 
$item['s_region'] != '' ) && ( $item['s_region'] != null ) ) { $addr[] = $item['s_region']; }
            if( ( 
$item['s_country'] != '' ) && ( $item['s_country'] != null ) ) { $addr[] = $item['s_country']; }
            
$address implode(", "$addr);
        
?>


So there is no need to modify or add anything.
If no address is given, it will show region.
If no region is given too, it will show country ....

Laure

  • Newbie
  • *
  • Posts: 1
Re: google maps: show region if the location is not specified
« Reply #3 on: February 17, 2014, 02:39:03 pm »
i have done it but I still have the same problem with my website. For my website in France it is ok http://fr.clasf.com/ as I am doing it with the postal codes but I can't do it for México http://www.clasf.mx/
They dont' let me choose the location catcher in map.php

Thank you for your help!

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: google maps: show region if the location is not specified
« Reply #4 on: February 17, 2014, 04:52:49 pm »
@Laure
You mean you are not able to use ZIPs in Mexico locations?
Can you check if there is no restriction on Google Geolocation script that would limit use of ZIPs in Mexico?

Puneet Dhawan

  • Newbie
  • *
  • Posts: 27
Re: google maps: show region if the location is not specified
« Reply #5 on: April 20, 2014, 03:32:35 pm »
to what frosticek has replied, you can add another line to maps.php to make the 'catcher' work better. When address is not entered it will show city area on the map after adding this -

Add:  if( ( $item['s_city_area'] != '' ) && ( $item['s_city_area'] != null ) ) { $addr[] = $item['s_city_area']; }
just below  if( ( $item['s_address'] != '' ) && ( $item['s_address'] != null ) ) { $addr[] = $item['s_address']; }

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: google maps: show region if the location is not specified
« Reply #6 on: April 20, 2014, 04:28:48 pm »
@Puneet Dhawan
I am using somewhere city area as field for mobile phone, so I left it :)

lucato

  • Full Member
  • ***
  • Posts: 182
  • [<o>] Brasil
Re: google maps: show region if the location is not specified
« Reply #7 on: July 11, 2015, 05:46:04 pm »
Guys,
If you download latest version of Google Maps Plugin, you can find location "catcher" in map.php file:
Code: [Select]
        <?php
            $addr 
= array();
            if( ( 
$item['s_address'] != '' ) && ( $item['s_address'] != null ) ) { $addr[] = $item['s_address']; }
            if( ( 
$item['s_city'] != '' ) && ( $item['s_city'] != null ) ) { $addr[] = $item['s_city']; }
            if( ( 
$item['s_zip'] != '' ) && ( $item['s_zip'] != null ) ) { $addr[] = $item['s_zip']; }
            if( ( 
$item['s_region'] != '' ) && ( $item['s_region'] != null ) ) { $addr[] = $item['s_region']; }
            if( ( 
$item['s_country'] != '' ) && ( $item['s_country'] != null ) ) { $addr[] = $item['s_country']; }
            
$address implode(", "$addr);
        
?>


So there is no need to modify or add anything.
If no address is given, it will show region.
If no region is given too, it will show country ....

That's is weird... if I comment out all this code, it still works when I edit the listing and change the city, region and so on. Any idea if there is another place that this code can control it besides plugins\google_maps\map.php ?

thanks