Return to Snippet

Revision: 34132
at November 5, 2010 03:27 by mikael12


Updated Code
function showMap() {
	var geocoder, map,
		gmap = document.getElementById('gmap'),
		adr = gmap.getAttribute('rel');

	geocoder = new google.maps.Geocoder();
	geocoder.geocode( { 'address': adr}, function(results, status) {
	  if (status == google.maps.GeocoderStatus.OK) {
		map = new google.maps.Map(document.getElementById("gmap"), {
		  zoom: 16,
		  center: results[0].geometry.location,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		});

		var marker = new google.maps.Marker({
			map: map,
			title: adr,
			position: results[0].geometry.location
		});

		var infowindow = new google.maps.InfoWindow({
			content: adr
		});

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

	  } else {
		alert("Nepodarilo sa nájsť lokalitu " + adr + ": " + status);
	  }
	});
}

function loadMap() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps/api/js?sensor=false&language=sk&callback=showMap";
  document.body.appendChild(script);
}

function chMap(adr) {
	var gmap = document.getElementById('gmap');

	gmap.setAttribute('rel', adr);
	showMap();
}

if (document.getElementById('gmap')) {
	window.onload = loadMap;
}

Revision: 34131
at October 17, 2010 23:24 by mikael12


Updated Code
var gmap = document.getElementById('gmap');

function showMap() {
	var geocoder, map, adr = gmap.getAttribute('rel');

	geocoder = new google.maps.Geocoder();
	geocoder.geocode( { 'address': adr}, function(results, status) {
	  if (status == google.maps.GeocoderStatus.OK) {
		map.setCenter(results[0].geometry.location);
		var marker = new google.maps.Marker({
			map: map,
			position: results[0].geometry.location
		});
	  } else {
		alert("Can't find " + adr + ": " + status);
	  }
	});

	map = new google.maps.Map(document.getElementById("gmap"), {
	  zoom: 16,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	});
}

function loadMap() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps/api/js?sensor=false&language=sk&callback=showMap";
  document.body.appendChild(script);
}

if (gmap) {
	window.onload = loadMap;
}

Revision: 34130
at October 17, 2010 23:23 by mikael12


Updated Code
var gmap = document.getElementById('gmap');

function showMap(adr) {
	var geocoder, map, adr = gmap.getAttribute('rel');

	geocoder = new google.maps.Geocoder();
	geocoder.geocode( { 'address': adr}, function(results, status) {
	  if (status == google.maps.GeocoderStatus.OK) {
		map.setCenter(results[0].geometry.location);
		var marker = new google.maps.Marker({
			map: map,
			position: results[0].geometry.location
		});
	  } else {
		alert("Nepodarilo sa n�¡js�¥ lokalitu: " + status);
	  }
	});

	map = new google.maps.Map(document.getElementById("gmap"), {
	  zoom: 16,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	});
}

function loadMap() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps/api/js?sensor=false&language=sk&callback=showMap";
  document.body.appendChild(script);
}

if (gmap) {
	window.onload = loadMap;
}

Revision: 34129
at October 17, 2010 23:23 by mikael12


Updated Code
var gmap = document.getElementById('gmap');

function showMap(adr) {
	var geocoder, map, adr = gmap.getAttribute('rel');

	geocoder = new google.maps.Geocoder();
	geocoder.geocode( { 'address': adr}, function(results, status) {
	  if (status == google.maps.GeocoderStatus.OK) {
		map.setCenter(results[0].geometry.location);
		var marker = new google.maps.Marker({
			map: map,
			position: results[0].geometry.location
		});
	  } else {
		alert("Nepodarilo sa nájsť lokalitu: " + status);
	  }
	});

	map = new google.maps.Map(document.getElementById("gmap"), {
	  zoom: 16,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	});
}

function loadMap() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps/api/js?sensor=false&language=sk&callback=showMap";
  document.body.appendChild(script);
}

if (gmap) {
	window.onload = loadMap;
}

Revision: 34128
at October 17, 2010 23:22 by mikael12


Initial Code
var gmap = document.getElementById('gmap');

function showMap(adr) {
	var geocoder, map, adr = gmap.getAttribute('rel');

	geocoder = new google.maps.Geocoder();
	geocoder.geocode( { 'address': adr}, function(results, status) {
	  if (status == google.maps.GeocoderStatus.OK) {
		map.setCenter(results[0].geometry.location);
		var marker = new google.maps.Marker({
			map: map,
			position: results[0].geometry.location
		});
	  } else {
		alert("Nepodarilo sa nájsť lokalitu: " + status);
	  }
	});

	map = new google.maps.Map(document.getElementById("gmap"), {
	  zoom: 16,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	});
}

function loadMap() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps/api/js?sensor=false&language=sk&callback=showMap";
  document.body.appendChild(script);
}

if (gmap) {
	window.onload = loadMap;
}

Initial URL

                                

Initial Description
Init markup <a id=\"gmap\" rel=\"New York\" ></a>

Initial Title
Google Map v3 async map

Initial Tags

                                

Initial Language
JavaScript