Switching between Google Maps to Mapbox

I’m currently using the Google Maps API but considering switching to Mapbox. My questions are:

  1. If I switch to Mapbox, will it continue to use the regions created by Google Maps API, or will Mapbox generate new regions?

  2. Is it possible to switch between Google Maps and Mapbox whenever needed to manage billing? Will this cause any issues or conflicts?

  3. Lastly, I want to add a full address, including door numbers, to vendor profiles. However, when I try entering an address like “186/6” in the location field, the correct address doesn’t appear in Google Maps. How can this be resolved?

Hi,

  1. Yes, it is best to select a provider before generating regions, as there may be issues as the names of regions may differ depending on the providers.

  2. There may be issues with regions only. Also, please note that, for example, Google Maps has a feature to hide the exact address, but MapBox does not.

  3. This is the expected behavior, as the API at the apartment level does not fill in this information as it is not a location. We recommend considering adding a separate field, “Additional information for the location,” for example.

​I hope this is helpful to you.

1 Like

Thank you for your response earlier!

I have another doubt: Is it possible to control map API calls for specific pages? I noticed that even if I hide the map using CSS, the API calls are still made in the backend. I’ve tried a few custom code snippets to control this behavior, but they didn’t work as expected.

Does HivePress have a built-in solution or any recommended method to manage map API calls efficiently?

Hi,

You can use this hook (if this is a listing page) hivepress/v1/templates/listing_view_page to remove the data-component=map from the entire block or to remove the entire block instead of hiding it with CSS. This way, this block will not be displayed in CSS, and the JS will not work.

I tried this, but not working.

add_filter(
    'hivepress/v1/templates/listing_view_page',
    function( $template ) {
        return hivepress()->helper->merge_trees(
            $template,
            [
                'blocks' => [
                    'listing_map' => null, // Remove the map block completely
                ],
            ]
        );
    },
    1000
);

It works as expected, and the map is hidden from the page. However, I have a doubt: Will this prevent the API call that loads the map from being made, or does it only hide the map on the front end while still allowing the API call to be executed in the background?

Yes, this should prevent the API calls since these are made only if there are HTML elements with data-component="map" attribute and the shared code snippet removes the element itself hivepress-geolocation/assets/js/common.js at master · hivepress/hivepress-geolocation · GitHub

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.