Google Maps API and Geocoding

This topic contains 3 replies, has 2 voices, and was last updated by  Alex Rollin 4 years, 5 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #516906

    gaz36f
    Expired Member
    Post count: 54

    I am trying to ensure that I keep costs to a minimum given the relatively new Google charges for map use.

    In a previous support post I read Alex state: “One thing you can do is use the new option for static maps on GD Maps for the GD Details template.”.

    Where is this option? I can’t find it and want to make sure it is enabled.

    Alex also stated; “Also of note, in 20065 we introduced a new, second Geocoding field. That means you can use OSM for map presentation (no charge) but then use Google for geocoding only.”

    Again, I am confused. How do I change the settings so that OSM is used for map presentation? In my advanced maps settings I currently have the same Google API key in both the ‘Google Maps API Key’ and ‘Google Geocoding API Key’ fields. Is this correct?

    I’ve read https://wpgeodirectory.com/google-maps-platform-changes-directory-developers/ but there is no information about actually settings etc.

    Many thanks, Gary

    #516938

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    we have extensive information about setup for maps here:

    https://wpgeodirectory.com/docs-v2/integrations/google/

    The geocoding key should probably different, since it should not be http referrer restricted.

    You can use this filter to change the maps API used on the add listing page
    https://github.com/AyeCode/geodirectory/blob/2e4d5a382f1e2e9d399ebbdfd321de8fdcf84fa3/includes/class-geodir-maps.php#L53

    #516959

    gaz36f
    Expired Member
    Post count: 54

    Sorry Alex, but I am still baffled.

    I have gone through the link you have sent me and I have removed the ‘Google Map API’ and kept the ‘Google Geocoding API Key’, which I have restricted to ‘Geocoding’ and ‘Timezone’ as per the articles suggestion.

    In terms of the filter, I don’t know what to do with it. I have used File Manager in CPanel to go to public_html>wp-content>plugins>geodirectory>includes>class-geodir-maps.php

    and I have found the snippet you highlighted: return apply_filters( ‘geodir_map_name’, $active_map );

    But I don’t know what to do with it. Am I supposed to ‘comment it out’?

    Basically, all I want to do is use Google Maps to add addresses in the listings page as OSM auto-address suggestions are terrible. For the rest of the site, I think I am happy for OSM to be used. Indeed, I am pretty happy not having a map at all but rather a link that opens people’s Google Maps on their phone or PC and they can use it to get directions etc.

    Is there a way to generate a Google Map link for each listing?

    Thanks again Alex.

    #517046

    Alex Rollin
    Moderator
    Post count: 27815

    Here’s a snippet that users the filter:

    
    
    
    /**
     * Load Google map on add listing page.
     */
    function gd_snippet_map_name( $map ) {
    	if ( geodir_is_page( 'add-listing' ) ) {
    		$map = 'google'; // google or osm
    	}
    
    	return $map;
    }
    add_filter( 'geodir_map_name', 'gd_snippet_map_name', 20, 1 );
    

    For more about snippets see: https://wpgeodirectory.com/docs-v2/faq/customizing/#snippets

    Use GD Post Directions for a link to the user’s map app for directions. Find that in the shortcode builder:

    https://wpgeodirectory.com/docs-v2/geodirectory/shortcode-builder/

Viewing 4 posts - 1 through 4 (of 4 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket