Google Maps Integration For third parties

Found a realy cool way of integrating google maps with third parties without the need of buying the google code module from Dolistore
Paste the following code on line 1595 in soc.php . The file is present inside Societe folder .

$establishment=$form->showrefnav($object, ‘socid’, ‘’, ($user->societe_id?0:1), ‘rowid’, ‘nom’)
$area=$object->address;
print "<tr><td></<td><td>
<div id=‘map34’ style=‘width:600px;height:370px;’ class='google_map '></div><script type=‘text/javascript’ src=‘http://maps.google.com/maps/api/js?sensor=false’></script><style type=‘text/css’>.google_map img {max-width: 100000%; /* override */}</style>
<script type=‘text/javascript’>
var latlng = new google.maps.LatLng(0, 0);
var myOptions = {
zoom: 15,
center: latlng,
scrollwheel: true,
scaleControl: false,
disableDefaultUI: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map34 = new google.maps.Map(document.getElementById(‘map34’),
myOptions);

	    var geocoder_map34 = new google.maps.Geocoder();
		var address = '$area,$object-\>state,$object-\>country';
		geocoder_map34.geocode( {'address': address}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				map34.setCenter(results[0].geometry.location);
				
					var marker = new google.maps.Marker({
						map: map34, 
						
						position: map34.getCenter()
					});
					
						var contentString = '$establishment';
						var infowindow = new google.maps.InfoWindow({
							content: contentString
						});
									
						google.maps.event.addListener(marker, 'click', function() {
						  infowindow.open(map34,marker);
						});
						
								infowindow.open(map34,marker);
							
			} else {
			alert('Geocode was not successful for the following reason: ' \+ status);
		}
		});
		</script\></td\></tr\>";
1 Like

SCREEN SHOT

Doesn’t work (anymore?) :dry:

/$establishment=$form->showrefnav($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');

$area=$object->address;

print "<tr><td></td><td>
	<div id='map34' style='width:600px;height:370px;' class='google_map '></div><script type='text/javascript' src='maps.google.com/maps/api/js?sensor=false'></script><style type='text/css'>.google_map img {max-width: 100000%; /* override */}</style>
	<script type='text/javascript'>
			var latlng = new google.maps.LatLng(0, 0);
			var myOptions = {
									zoom: 15,
									center: latlng,
									scrollwheel: true,
									scaleControl: false,
									disableDefaultUI: false,
									mapTypeId: google.maps.MapTypeId.ROADMAP
							};
			var map34 = new google.maps.Map(document.getElementById('map34'),myOptions);

			var geocoder_map34 = new google.maps.Geocoder();
			var address = '$area,$object->state,$object->country';

			geocoder_map34.geocode( {'address': address}, function(results, status) {
					if (status == google.maps.GeocoderStatus.OK) {
							map34.setCenter(results[0].geometry.location);

							var marker = new google.maps.Marker({
																	map: map34,
																	position: map34.getCenter()
															});

							var contentString = '$establishment';
							var infowindow = new google.maps.InfoWindow({
																			content: contentString
															});

							google.maps.event.addListener(marker, 'click', function() {
																							infowindow.open(map34,marker);
															});

							infowindow.open(map34,marker);

					} else {
							alert('Geocode was not successful for the following reason: ' + status);
					}
			});
	</script>
</td></tr>"; 

Best regards

It DOES work! Version is GPL for Dolibar 3.2.

Try it on your own risk.

(For complete Google Module with more features: https://www.dolistore.com/en/modules/294-google.html?search_query=google&results=8 )

cd .../htdocs
wget https://github.com/darkslategrey/dolibarr-google/archive/master.zip
unzip master.zip
mv dolibarr-google* google
chown -R [user]:[group] google

Setup Modules -> Interface Modules -> Google
Zoom = 9 !!! (NOT 10)

Best regards