Integration with Google Maps

Click marker to make menu appear
</> Source
<!DOCTYPE html>
<html>
<head>
	<title>Integration with Google Maps</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
	<script src="../../../codebase/dhtmlx.js"></script>
	<style>
		div#maps_here {
			position: relative;
			margin-left: 20px;
			width: 600px;
			height: 400px;
			border: 1px solid #c0c0c0;
		}
		div.demo_info {
			position: relative;
			padding: 20px;
			font-family: Tahoma;
			font-size: 16px;
			color: #333;
		}
	</style>
	<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
	<script>
		var myMenu;
		var GMaps, Marker, Overlay;
		var NY = {lat: 40.719837, lng: -73.992348};
		var mapOfs = {};
		function doOnLoad() {
			
			myMenu = new dhtmlXMenuObject({
				icons_path: "../../../dhtmlxMenu/samples/common/imgs_maps/",
				context: true,
				json: [
					{text: "Add to favorites", img: "fav.gif"},
					{text: "Add new tag", img: "add_new_tag.gif"},
					{text: "Open gallery", img: "open_gallery.gif"},
					{type: "separator"},
					{text: "Print map", img: "print.gif"},
					{text: "Save as...", img: "save.gif"},
					{type: "separator"},
					{text: "Delete marker", img: "close.gif"}
				]
			});
			var t = document.getElementById("maps_here");
			mapOfs = {x: dhx4.absLeft(t), y: dhx4.absTop(t)};
			GMaps = new google.maps.Map(t, {
				center: new google.maps.LatLng(NY.lat, NY.lng),
				zoom: 11,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			});
			
			Marker = new google.maps.Marker({
				position: new google.maps.LatLng(NY.lat, NY.lng),
				title: "Hello",
				map: GMaps
			});
			
			google.maps.event.addListener(GMaps, "projection_changed", function(){
				
				Overlay = new google.maps.OverlayView();
				Overlay.setMap(GMaps);
				Overlay.draw = function(){}
				
				google.maps.event.addListener(Marker, "click", function(e){
					var k = Overlay.getProjection().fromLatLngToContainerPixel(e.latLng);
					window.setTimeout(function(){
						myMenu.showContextMenu(Math.round(k.x)+mapOfs.x, Math.round(k.y)+mapOfs.y-20);
					},1);
				});
			});
			
		}
	</script>
</head>
<body onload="doOnLoad();">
	<div class="demo_info">Click marker to make menu appear</div>
	<div id="maps_here"></div>
</body>
</html>

Documentation

Check documentation to learn how to use the components and easily implement them in your applications.