News:

Looking for documentation? Take a look on our wiki

Main Menu

Using google maps in product

Started by nav007_2000, July 23, 2012, 19:59:38 PM

Previous topic - Next topic

nav007_2000

Hi Ivus

Custom fields are

Address ID 4
City ID 5
Post code ID 6

ivus

OK try this.



<?php

$address NULL;
$city NULL;
$postcode NULL;
$country "US";

foreach ($this->product->customfieldsSorted['normal'] as $customfields) :

switch ($customfields->virtuemart_custom_id) {
case 4:
$address $customfields->display;
break;
case 5:
$city $customfields->display;
break;
case 6:
$postcode $customfields->display;
break;
}

endforeach;

$fullAddress nl2br($address).','.$city.','.$postcode.','.$country;
$fulladdressEsc ereg_replace(' ','+',$fullAddress);
$geocode file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$fulladdressEsc.'&sensor=false');
$output json_decode($geocode);
$googlemapLat $output->results[0]->geometry->location->lat;
$googlemapLong $output->results[0]->geometry->location->lng;

?>

<style>
.__loc_mapContainer {
width:934px;
display:block;
height:305px;
margin-top:30px;
margin-left:auto;
margin-right:auto;
position:relative;
cursor:pointer;
clear:both;
border:solid 3px #434244;
background-color:#b9298b;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initializeMap() {
var latlng = new google.maps.LatLng(<?php echo $googlemapLat?>,<?php echo $googlemapLong?>);
var settings = {
zoom: 14,
center: latlng,
mapTypeControl: false,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: true,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
var companyMarker = new google.maps.Marker({
position: latlng,
map: map,
zIndex: 3});
}
</script>
<div id="map_canvas" class="__loc_mapContainer"></div>
<script type="text/javascript">
initializeMap();
</script>


nav007_2000

That didnt bring up the map. Nor did it show up an error. Maybe the custom fields are not going into the array? :(


nav007_2000

where can i place the class on my server? would that be within the joomla directory or the virtue mart directory?