Jump to content

Add supplier position on google map on product page


Roman0002

Recommended Posts

Hi, 
 
I would like to add supplier position on google map on product page to description.
I've copy this code to product.tpl but it does not work:
 
        <script type="text/javascript">
var geocoder = new google.maps.Geocoder();
var delivery_map;
 
$(document).ready(function()
{
$(".textarea-autosize").autosize();
 
geocoder.geocode({
address: '{$supplier_address->address1},{$supplier_address->postcode},{$supplier_address->city},{$supplier_address->country}'
}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK)
{
delivery_map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: results[0].geometry.location
});
var delivery_marker = new google.maps.Marker({
map: delivery_map,
position: results[0].geometry.location,
url: 'http://maps.google.com?q={$supplier_address->address1|urlencode},{$supplier_address->postcode|urlencode},{$supplier_address->city|urlencode},{$supplier_address->country|urlencode}'
});
google.maps.event.addListener(delivery_marker, 'click', function() {
window.open(delivery_marker.url);
});
}
}
 
var date = new Date();
var hours = date.getHours();
if (hours < 10)
hours = "0" + hours;
var mins = date.getMinutes();
if (mins < 10)
mins = "0" + mins;
var secs = date.getSeconds();
if (secs < 10)
secs = "0" + secs;
 
$('.datepicker').datetimepicker({
prevText: '',
nextText: '',
dateFormat: 'yy-mm-dd ' + hours + ':' + mins + ':' + secs
});
});
 
// Fix wrong maps center when map is hidden
$('#tabAddresses').click(function(){
x = delivery_map.getZoom();
c = delivery_map.getCenter();
google.maps.event.trigger(delivery_map, 'resize');
delivery_map.setZoom(x);
delivery_map.setCenter©;
 
x = invoice_map.getZoom();
c = invoice_map.getCenter();
google.maps.event.trigger(invoice_map, 'resize');
invoice_map.setZoom(x);
invoice_map.setCenter©;
});
</script>
 
Please help me 
 
For help and answers thank you in advance
 

 

post-834801-0-48555500-1414253268_thumb.png

Link to comment
Share on other sites

  • 7 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...