Hi all,
We have a locations page that pulls info from the inventory sources module/information from the backend (stores > inventory > sources). (https://www.clampitt.com/locations). We like this page, like the form at the top, etc., so we would prefer to keep it.
However, we'd like to use those coordinates to show as a 'view map' link, or even make the address a map link.
How can we do this? Has anyone done this?
Bringing in Google maps is not an option, and while I've looked at other solutions/extensions, I feel like this should be relatively easy...
Hi,
Google provides a way to view maps using a link with latitude and longitude.
You can use the following code:
<?php foreach ($sources as $source): ?> <?php $latitude = $source->getLatitude(); $longitude = $source->getLongitude(); ?> <div class="location-item"> <a href="https://www.google.com/maps?q=<?= $latitude ?>,<?= $longitude ?>" target="_blank"> View Map </a> </div> <?php endforeach; ?>
Mageplaza | Top-Rated Magento Extension and Solution Provider
Should you have any questions or concerns, feel free to contact us via consultant@mageplaza.com