Click here to Skip to main content
15,891,943 members
Articles / Web Development / HTML

Google Maps in WPF with WebBrowser and Google Maps API v3

Rate me:
Please Sign up or sign in to vote.
4.69/5 (15 votes)
13 Mar 2017CPOL5 min read 125.6K   13.3K   51  
You can show a map in your WPF application with the Google Maps API v3.
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html, body {
  height: 99.2%;
  margin: 0;
  padding: 0;
}

#map_canvas {
  height: 100%;
  border-color:red;
  border-style:groove;
  border-width:5px;
}

#content
{
  width: 270px;
  background-color:green;
  color:white;
}
</style>
<script type="text/javascript" src="http://maps.google.com.mx/maps/api/js?sensor=true&language=es"></script>
<script src='http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js'></script>
<script type="text/javascript">
  var map;
	var markers = [];
  function initialize() {
        map= new google.maps.Map(document.getElementById('map_canvas'), 
				{
					zoom: 18,
					center: new google.maps.LatLng(25.520581,-103.40607),
					mapTypeId: google.maps.MapTypeId.SATELLITE,
					disableDefaultUI: true,
					zoomControl: true,
					maxZoom: 19
				});
  }
      function addMarker( Lat, Long)
			{
				var latLng = new google.maps.LatLng(Lat , Long); 		
				marker = new google.maps.Marker				
				(
					{
						position:   latLng,
						
	          animation:  google.maps.Animation.DROP,
            title:"Click for show the data of the client"
					}
				);
				markers.push(marker);			  				
		    var markerCluster = new MarkerClusterer(map, markers);		
			}  
</script>
</head>
<body onload="initialize()">
  	<button type="button" onclick="addMarker(25.520581,-103.40607, 'cliente','client1.png','direccion')" title="Add Marker">Add Marker</button> 
		
  <div id="map_canvas"></div>
</body>
</html> 

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer armheSistemas
Mexico Mexico
I'm a software developer. I like to develop web pages and desktop systems. I'm learning unity, xamarin, swift, android, security, UX

Comments and Discussions