Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <script src=";sensor=false&amp;language=en" type="text/javascript"></script>

<h1>Google maps API v.3</h1>

    <label for="addr"><strong>Address</strong></label><br>
    <input id="addr" type="text" value="Castel Sant'Angelo, Rome, Italy" size="80">
    <button id="creaMappa" type="button">Build map</button>
<p>Drag the cursor to change coordinates</p>
<p><strong>Coords</strong>: <span id="lat">--</span>, <span id="lng">--</span></p>
<div class="map" id="map1"></div>

<h2>Reverse Geocoding</h2>
<p>Retrieve coordinates first, then trigger reverse geocoding:</p>
<p><button id="reverseGeocoding" type="button">Reverse Geocoding</button></p>
<p>Reverse Geocoding result formatted_address: <span id="reverseGeocodingResult_formatted_address">--</span></p>
<p>Reverse Geocoding result address components:</p>
    <span class=""><span id="reverseGeocodingResult_address_components">--</span></span>
<p>NB: change the <code>language</code> url parameter to reverse geocode in other languages</p>

<p class="p">Demo by Massimo Cassandro. <a href="">See article</a>.</p>


                body {
  text-align: center;

iframe {
  display: block;
  margin: auto;

.map {
  border: 1px solid #ccc;
  background-color: #efefef;
  height: 300px;


                $(document).ready(function() {
	var geocoder;
	var map;
	$('#creaMappa').click(function () {
		var address=$('#addr').val();
		geocoder = new google.maps.Geocoder();
		geocoder.geocode( { 'address': address}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				console.log('geocoder results:');
				var mapOptions = {
					zoom: 16,
					mapTypeControl: true,
					mapTypeControlOptions: {
					  style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
					zoomControl: true,
					zoomControlOptions: {
					  style: google.maps.ZoomControlStyle.SMALL
					//streetViewControl: false,
					center: results[0].geometry.location
				map = new google.maps.Map(document.getElementById('map1'), mapOptions);
				var marker = new google.maps.Marker({
					map: map,
					position: results[0].geometry.location,
					draggable: true,
					animation: google.maps.Animation.DROP
				google.maps.event.addListener(marker, 'dragend', function() {
					var marker_pos=marker.getPosition();
					console.log('Marker getPosition():');
			} else {
				alert('Si \u00E8 verificato un problema nel generare la mappa (' + status + ')');
	$('#reverseGeocoding').click(function () {
		var lat = parseFloat($('#lat').text());
		var lng = parseFloat($('#lng').text());
		var latlng = new google.maps.LatLng(lat, lng);
		geocoder.geocode({'latLng': latlng}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				console.log('Reverse Geocoding:');
				// address components: recupero di tutti gli elementi 
				console.log('Address components:');
				var temp=[];
				for(var i=0; i<results[0].address_components.length; i++) {
					if($.inArray(results[0].address_components[i].long_name, temp) === -1) { // evita potenziali duplicati
					if($.inArray(results[0].address_components[i].short_name, temp) === -1) { // evita potenziali duplicati
				console.log('Address components (elaborati):');
			} else {
				alert("Geocoder failed due to: " + status);