Index: extensions/rv_gmaps/trunk/map.php
===================================================================
--- extensions/rv_gmaps/trunk/map.php	(revision 12367)
+++ extensions/rv_gmaps/trunk/map.php	(revision 12698)
@@ -84,5 +84,5 @@
 }
 else
-  $template->assign('MAP_MARKER_ICON_JS', 'return G_DEFAULT_ICON;');
+  $template->assign('MAP_MARKER_ICON_JS', 'return {}');
 
 $template->pparse('map');
Index: extensions/rv_gmaps/trunk/map_data.php
===================================================================
--- extensions/rv_gmaps/trunk/map_data.php	(revision 12367)
+++ extensions/rv_gmaps/trunk/map_data.php	(revision 12698)
@@ -63,10 +63,10 @@
 function jsgm_position( $position )
 {
-  return 'new GLatLng(' . $position['lat'] . ',' . $position['lon'] . ')';
+  return 'new google.maps.LatLng(' . $position['lat'] . ',' . $position['lon'] . ')';
 }
 
 function jsgm_bounds( $bounds )
 {
-  return 'new GLatLngBounds(' . jsgm_position(bounds_sw($bounds)) . ',' . jsgm_position(bounds_ne($bounds)) . ')';
+  return 'new google.maps.LatLngBounds(' . jsgm_position(bounds_sw($bounds)) . ',' . jsgm_position(bounds_ne($bounds)) . ')';
 }
 
Index: extensions/rv_gmaps/trunk/template/data_handler.js
===================================================================
--- extensions/rv_gmaps/trunk/template/data_handler.js	(revision 12367)
+++ extensions/rv_gmaps/trunk/template/data_handler.js	(revision 12698)
@@ -3,12 +3,13 @@
 {
 	this._map = map;
+	this._infoWindow = new google.maps.InfoWindow();
 	this.options = jQuery.fn.extend(
 		{
-			icon: G_DEFAULT_ICON,
+			markerOptions: {},
 			show_all_img_src: null
 		}
 		, opts || {} );
 
-	google.maps.Event.addListener( map, "infowindowclose", function() {map.getInfoWindow().pwgMarker=null;} );
+	google.maps.event.addListener( map, "infowindowclose", function() {map.getInfoWindow().pwgMarker=null;} );
 }
 
@@ -16,4 +17,5 @@
 
 _map: null,
+_infoWindow: null,
 options: {},
 _markers: [],
@@ -60,5 +62,5 @@
 	{
 		changed = false;
-		if (this._markers.length>0 && !this._markers[0].getLatLng().equals( data.image_clusters[0].position ) )
+		if (this._markers.length>0 && !this._markers[0].getPosition().equals( data.image_clusters[0].position ) )
 			changed=true;
 	}
@@ -67,5 +69,5 @@
 	{
 		var newMarkers = [];
-		var infoWindowMarker = this._map.getInfoWindow().pwgMarker;
+		var infoWindowMarker = this._infoWindow.pwgMarker;
 
 		for (i=0; i<data.image_clusters.length; i++)
@@ -82,9 +84,9 @@
 			if (marker && marker==infoWindowMarker)
 			{
-				this._map.removeOverlay( marker );
-				google.maps.Event.clearListeners(marker, "click" );
-				google.maps.Event.clearListeners(marker, "dblclick" );
-				this._map.getInfoWindow().pwgMarker = infoWindowMarker = null;
-				if (document.is_debug) google.maps.Log.write('removed marker with infoWindow');
+        marker.setMap(null);
+				google.maps.event.clearListeners(marker, "click" );
+				google.maps.event.clearListeners(marker, "dblclick" );
+				this._infoWindow.pwgMarker = infoWindowMarker = null;
+				if (document.is_debug) glog('removed marker with infoWindow');
 				marker = this._markers.pop();
 			}
@@ -92,41 +94,17 @@
 			if (!marker)
 			{
-				marker = new google.maps.Marker( cluster.position, {title:  theTitle, icon: this.options.icon } );
-				google.maps.Event.addListener( marker, "click", pwgBind(this, this._onMarkerClick, marker) );
-				google.maps.Event.addListener( marker, "dblclick", pwgBind(this, this._onMarkerDblClick, marker) );
-				this._map.addOverlay( marker );
+				marker = new google.maps.Marker(this.options.markerOptions);
+        marker.setPosition(cluster.position);
+        marker.setTitle(theTitle);
+				google.maps.event.addListener( marker, "click", pwgBind(this, this._onMarkerClick, marker) );
+				google.maps.event.addListener( marker, "dblclick", pwgBind(this, this._onMarkerDblClick, marker) );
+        marker.setMap(this._map);
 			}
 			else
 			{
 				marker.currentImageIndex=0;
-				marker.setLatLng( cluster.position );
-				// changing the marker title is undocumented so we hack it
-				if (!this.hack)
-				{
-					this.hack = {};
-					for (var prop in marker)
-					{
-						if ( typeof(marker[prop])!='object') continue;
-						if (!this.hack.markerHtmlElemWithTitle )
-						{
-							try {
-								if (eval("typeof marker." + prop + "[0].src") == "string" && eval("typeof marker." + prop + "[0].title") == "string" )
-									this.hack.markerHtmlElemWithTitle = prop;
-							}
-							catch (e) {}
-						}
-						if (!this.hack.markerOptions)
-							try {
-								if ( eval("typeof marker."+prop+".title")=="string" && eval("typeof marker."+prop+".src")=="undefined")
-									this.hack.markerOptions = prop;
-							}
-							catch (e) {}
-					}
-				}
-				//undocumented marker.K , marker.ch and marker.jb and marker.l
-				if (this.hack.markerOptions)
-					eval( 'marker.'+this.hack.markerOptions+'.title=theTitle');
-				if (this.hack.markerHtmlElemWithTitle)
-					eval( 'marker.'+this.hack.markerHtmlElemWithTitle+'[0].title=theTitle');
+				marker.setPosition( cluster.position );
+				marker.setTitle(theTitle);
+				marker.setMap(this._map);
 			}
 
@@ -143,7 +121,7 @@
 		for (i=0; i<this._markers.length; i++)
 		{
-			this._map.removeOverlay( this._markers[i] );
-			google.maps.Event.clearListeners(this._markers[i], "click" );
-			google.maps.Event.clearListeners(this._markers[i], "dblclick" );
+			this._markers[i].setMap(null);
+			google.maps.event.clearListeners(this._markers[i], "click" );
+			google.maps.event.clearListeners(this._markers[i], "dblclick" );
 		}
 
@@ -158,5 +136,5 @@
 _onMarkerClick: function( marker )
 {
-	if (this._map.getInfoWindow().pwgMarker == marker )
+	if (this._infoWindow.pwgMarker == marker )
 		return; // already open
 	var content = "";
@@ -182,5 +160,7 @@
 	content += '<div id="pwgImageDetail">' + this.buildCurrentPictureHtml( marker ) + '</div>';
 
-	marker.openInfoWindowHtml( content );
+	this._infoWindow.setContent( content );
+	this._infoWindow.setPosition( marker.getPosition() );
+	this._infoWindow.open( this._map );
 
 	// bind to next / prev a little later because sometimes the nodes are not immediately created
@@ -193,5 +173,5 @@
 _onMarkerDblClick: function( marker )
 {
-	this._map.setCenter( marker.pwg.bounds.getCenter(), this._map.getBoundsZoomLevel( marker.pwg.bounds ) );
+	this._map.fitBounds( marker.pwg.bounds );
 },
 
@@ -228,10 +208,10 @@
 	clearTimeout(this._timerBindPictureNavigation);
 	this._timerBindPictureNavigation = null;
-	this._map.getInfoWindow().pwgMarker = marker;
+	this._infoWindow.pwgMarker = marker;
 	for (var i=0; i< this._navHtmlIds.length; i++)
 	{
 		var elt = document.getElementById( this._navHtmlIds[i] );
 		if (elt)
-			google.maps.Event.addDomListener(elt, "click", pwgBind(this, this._onPictureNavigate, marker, i) );
+			google.maps.event.addDomListener(elt, "click", pwgBind(this, this._onPictureNavigate, marker, i) );
 	}
 },
Index: extensions/rv_gmaps/trunk/template/data_loader.js
===================================================================
--- extensions/rv_gmaps/trunk/template/data_loader.js	(revision 12367)
+++ extensions/rv_gmaps/trunk/template/data_loader.js	(revision 12698)
@@ -4,6 +4,6 @@
 	this.options = jQuery.fn.extend(
 		{
-			reload_data_timeout: 1800,
-			rectangle_of_confusion: G_DEFAULT_ICON.iconSize
+			reload_data_timeout: 500,
+			rectangle_of_confusion: new google.maps.Size(32,16)
 		}
 		, opts || {} );
@@ -37,7 +37,7 @@
 {
 	this._urlMapData = urlMapData;
-	google.maps.Event.bind( this._map, "movestart", this, this.clearTimerReloadData );
-	google.maps.Event.bind( this._map, "moveend", this, this._onMapMoveEnd );
-	this._loadData();
+	google.maps.event.bind( this._map, "movestart", this, this.clearTimerReloadData );
+	google.maps.event.bind( this._map, "idle", this, this._onIdle );
+	//this._loadData();
 },
 
@@ -59,5 +59,5 @@
 },
 
-_onMapMoveEnd: function()
+_onIdle: function()
 {
 	this.clearTimerReloadData();
@@ -78,12 +78,13 @@
 
 	var latRange = bounds.toSpan().lat();
-	var latPrec = latRange * this.options.rectangle_of_confusion.height / this._map.getSize().height;
+	var latPrec = latRange * this.options.rectangle_of_confusion.height / this._map.getDiv().offsetHeight;
 
 	var lonRange = bounds.toSpan().lng();
-	var lonPrec = ( lonRange>=0 ? lonRange : 360-lonRange )* this.options.rectangle_of_confusion.width / this._map.getSize().width;
+	var lonPrec = ( lonRange>=0 ? lonRange : 360-lonRange )* this.options.rectangle_of_confusion.width / this._map.getDiv().offsetWidth;
 
 	if ( this._previousLoadDataReq.box!=null )
 	{ // not the first time
-		if ( this._previousLoadDataReq.box.containsBounds( bounds ) )
+		if ( this._previousLoadDataReq.box.contains( bounds.getNorthEast() )
+					&& this._previousLoadDataReq.box.contains( bounds.getSouthWest() ))
 		{
 			if ( this._previousLoadDataReq.resultBounds == null )
@@ -109,10 +110,10 @@
 
 	var nd=0, sd=0, ed=0, wd=0;
-	if ( !bounds.isFullLat() )
+	/*if ( !bounds.isFullLat() )*/
 	{
 		nd = latRange*12/100;
 		sd = latRange*4/100;
 	}
-	if ( !bounds.isFullLng() )
+	/*if ( !bounds.isFullLng() )*/
 	{
 		ed = lonRange*9/100;
@@ -130,7 +131,6 @@
 
 	if (document.is_debug) {
-		google.maps.Log.write("sd="+sd+" wd="+wd+" nd="+nd+" ed="+ed);
-		google.maps.Log.write( "bounds: " + this._map.getBounds().getSouthWest().toUrlValue() + " " + this._map.getBounds().getNorthEast().toUrlValue() +"; zoom: "+this._map.getZoom() +"; size: "+this._map.getSize().toString() +"; c: "+this._map.getCenter().toUrlValue() );
-		google.maps.Log.writeUrl( url );
+		glog("sd="+sd+" wd="+wd+" nd="+nd+" ed="+ed);
+		glog( url );
 	}
 
@@ -141,5 +141,5 @@
 
 	try {
-		google.maps.Event.trigger( this, "dataloading" );
+		google.maps.event.trigger( this, "dataloading" );
 		jQuery.ajax( {
 			url: url,
@@ -151,5 +151,5 @@
 		this._dataLoading = false;
 		this._previousLoadDataReq.box=null;
-		google.maps.Event.trigger( this, "dataloadfailed", 600, e );
+		google.maps.event.trigger( this, "dataloadfailed", 600, e );
 	}
 },
@@ -164,10 +164,10 @@
 			throw new Error( "DATA DECODING ERROR" );
 		this._previousLoadDataReq.resultBounds = resp.bounds;
-		if (document.is_debug && resp.debug) google.maps.Log.write( resp.debug );
-		google.maps.Event.trigger( this, "dataloaded", resp );
+		if (document.is_debug && resp.debug) glog( resp.debug );
+		google.maps.event.trigger( this, "dataloaded", resp );
 	}
 	catch (e)	{
 		this._previousLoadDataReq.box=null;
-		google.maps.Event.trigger( this, "dataloadfailed", responseCode, e );
+		google.maps.event.trigger( this, "dataloadfailed", responseCode, e );
 		var s = e.message;
 		s += '\n' + data.substr(0,1000);
@@ -182,5 +182,5 @@
 {
 	try {
-		google.maps.Event.trigger( this, "dataloadfailed", textStatus + xhr.status, exc );
+		google.maps.event.trigger( this, "dataloadfailed", textStatus + xhr.status, exc );
 	}
 	catch (e) {
Index: extensions/rv_gmaps/trunk/template/map.tpl
===================================================================
--- extensions/rv_gmaps/trunk/template/map.tpl	(revision 12367)
+++ extensions/rv_gmaps/trunk/template/map.tpl	(revision 12698)
@@ -1,10 +1,11 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
 <head>
 <meta http-equiv="content-type" content="text/html; charset={$CONTENT_ENCODING}" />
+<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
 <meta name="robots" content="noindex,nofollow" />
 <title>{$GALLERY_TITLE}</title>
 
-<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={$GMAPS_API_KEY}&amp;hl={$lang_info.code}" type="text/javascript"></script>
+<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;language={$lang_info.code}" type="text/javascript"></script>
 
 {combine_script id='jquery' load='header' path='http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'}
@@ -46,45 +47,53 @@
 	document._window = window;
 }
-  
+
+function glog(msg) {
+	if (console)
+	{
+		console.debug(msg + " b="+map.getBounds().toUrlValue() + " c="+map.getCenter().toUrlValue() + " z="+map.getZoom() );
+	}
+}
+
 function load()
 {
-	if (!GBrowserIsCompatible())
-	return;
-
-	var mapElement = document.getElementById("map");
-	map = new google.maps.Map2( mapElement );
-
-	map.addMapType( G_PHYSICAL_MAP );
-	map.addControl(new google.maps.LargeMapControl3D());
-	map.addControl(new google.maps.HierarchicalMapTypeControl());
-	map.addControl(new google.maps.ScaleControl());
-
-	pwgPageLinker = new PageLinker(map, "aLinkToThisPage" );
-	if ( !map.isLoaded() )
+	var mapOptions = {
+		mapTypeId: google.maps.MapTypeId.ROADMAP,
+		overviewMapControl: true
+	}
+
+	if (1/*!PageLinker.url2Map(mapOptions)*/)
 	{
 {/literal}
 		{if isset($initial_bounds)}
-		var bounds = new google.maps.LatLngBounds( new google.maps.LatLng({$initial_bounds.s},{$initial_bounds.w}), new google.maps.LatLng({$initial_bounds.n},{$initial_bounds.e}) );
-		map.setCenter( bounds.getCenter(), map.getBoundsZoomLevel( bounds ) );
+		mapOptions.iniBounds = new google.maps.LatLngBounds( new google.maps.LatLng({$initial_bounds.s},{$initial_bounds.w}), new google.maps.LatLng({$initial_bounds.n},{$initial_bounds.e}) );
+		mapOptions.center = mapOptions.iniBounds.getCenter();
+		{else}
+			mapOptions.center = new google.maps.LatLng(0,0);
+			mapOptions.zoom = 2;
 		{/if}
 {literal}
-		if ( !map.isLoaded() )
-			map.setCenter( new google.maps.LatLng(0,0), 2 );
-	}
-
-	try {
-		// the overview must be added after setting map center
-		var ovcontrol = new google.maps.OverviewMapControl(new google.maps.Size(165,165));
-		map.addControl(ovcontrol);
-	}
-	catch(e){ alert( e.message ); }
-
-	map.enableScrollWheelZoom();
-	map.enableDoubleClickZoom();
-
-	var pwgMarkerIcon = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null);
-
-	map.pwgDataLoader = new PwgDataLoader(map, {rectangle_of_confusion: pwgMarkerIcon.iconSize} );
-	google.maps.Event.addListener(map.pwgDataLoader, "dataloading", function() {
+	}
+
+	map = new google.maps.Map( document.getElementById("map"), mapOptions );
+	
+	if (mapOptions.iniBounds)
+		map.fitBounds(mapOptions.iniBounds);
+
+	if (document.is_debug)
+	{
+		google.maps.event.addListener(map, "idle", function() { glog("idle"); });
+		google.maps.event.addListener(map, "bounds_changed", function() { glog("bounds_changed");} );
+		google.maps.event.addListener(map, "center_changed", function() { glog("center_changed");} );
+		google.maps.event.addListener(map, "maptypeid_changed", function() { glog("maptypeid_changed");} );
+		google.maps.event.addListener(map, "zoom_changed", function() { glog("zoom_changed");} );
+		google.maps.event.addListener(map, "drag", function() { glog("drag");} );
+	}
+
+	pwgPageLinker = new PageLinker(map, "aLinkToThisPage" );
+
+	var pwgMarkerOptions = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null);
+
+	map.pwgDataLoader = new PwgDataLoader(map, {rectangle_of_confusion: pwgMarkerOptions.roc} );
+	google.maps.event.addListener(map.pwgDataLoader, "dataloading", function() {
 		var pre = '<img src="{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/progress_s.gif" width="16" height="16" alt="~" /> ';
 		document.getElementById("dataLoadStatus").innerHTML = pre + Localization.get("Loading");
@@ -92,21 +101,13 @@
 	);
   
-	google.maps.Event.addListener(map.pwgDataLoader, "dataloadfailed", function(responseCode) {
+	google.maps.event.addListener(map.pwgDataLoader, "dataloadfailed", function(responseCode) {
 		document.getElementById("dataLoadStatus").innerHTML = Localization.get("Failed") + " "+responseCode;
 		}
 		);
 
-	map.pwgDataHandler = new PwgDataHandler(map, {icon: pwgMarkerIcon, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } );
-	google.maps.Event.addListener(map.pwgDataLoader, "dataloaded", pwgBind(map.pwgDataHandler, map.pwgDataHandler.handle) );
+	map.pwgDataHandler = new PwgDataHandler(map, {icon: pwgMarkerOptions, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } );
+	google.maps.event.addListener(map.pwgDataLoader, "dataloaded", pwgBind(map.pwgDataHandler, map.pwgDataHandler.handle) );
 
 	map.pwgDataLoader.start( "{/literal}{$U_MAP_DATA}{literal}" );
-
-	if (document.is_debug)
-	{
-		google.maps.Event.addListener(map, "moveend", function() { google.maps.Log.write("movend c:"+map.getCenter().toUrlValue());} );
-		google.maps.Event.addListener(map, "maptypechanged", function() { google.maps.Log.write("maptypechanged");} );
-		google.maps.Event.addListener(map, "infowindowopen", function() { google.maps.Log.write("infowindowopen");} );
-		google.maps.Event.addListener(map, "infowindowclose", function() { google.maps.Log.write("infowindowclose");} );
-	}
 }
 
@@ -118,5 +119,4 @@
 		!map.pwgDataHandler || map.pwgDataHandler.terminate();
 	}
-	GUnload();
 }
 
@@ -125,29 +125,14 @@
 	if (!q.length) return false;
 	if (!geocoder)
-		geocoder = new google.maps.ClientGeocoder();
-	geocoder.getLocations(q, function(resp)
-	  {
-		if ( resp && resp.Status )
+		geocoder = new google.maps.Geocoder();
+	geocoder.geocode(q, function(results, status) {
+		document._geoResponse = results;
+		if ( status == google.maps.GeocoderStatus.OK )
 		{
-		  document._geoResponse = resp;
-		  if (resp.Status.code==200)
-		  {
-			var zoom = 2;
-			switch (resp.Placemark[0].AddressDetails.Accuracy)
-			{
-			  case 1: zoom=5; break; //country
-			  case 2: zoom=7; break; //region
-			  case 3: zoom=8; break; //county
-			  case 4: zoom=12; break; //town
-			  case 5: zoom=13; break; //post code
-			  case 6: zoom=14; break; //street
-			  case 7: case 8: zoom=16; break; //intersection/exact
-			}
-			map.setCenter( new google.maps.LatLng( resp.Placemark[0].Point.coordinates[1], resp.Placemark[0].Point.coordinates[0] ), zoom);
-		  }
-		  else
-			alert("This address has not been found\nCode:"+resp.Status.code);
-		}
-	  });
+			map.fitBounds( results[0].geometry.viewport );
+		}
+	  else
+			alert("This address has not been found\nCode: "+status);
+	});
 	return false;
 }
Index: extensions/rv_gmaps/trunk/template/page_linker.js
===================================================================
--- extensions/rv_gmaps/trunk/template/page_linker.js	(revision 12367)
+++ extensions/rv_gmaps/trunk/template/page_linker.js	(revision 12698)
@@ -4,10 +4,6 @@
   this._elementId = aElementId;
 
-  PageLinker.url2Map( map );
-  
-  google.maps.Event.bind( this._map, "maptypechanged", this, this._regenerateUrl );
-  google.maps.Event.bind( this._map, "moveend", this, this._regenerateUrl );
-  if ( this._map.isLoaded() )
-    this._regenerateUrl();
+  google.maps.event.bind( this._map, "idle", this, this._regenerateUrl );
+  google.maps.event.bind( this._map, "maptypeid_changed", this, this._regenerateUrl );
 }
 
@@ -32,8 +28,8 @@
   vars['ll'] = map.getCenter().toUrlValue(5);
   vars['z'] = map.getZoom();
-  if ( map.getCurrentMapType()===G_NORMAL_MAP )
+  if ( map.getMapTypeId()===google.maps.MapTypeId.ROADMAP )
     { if (vars['t']) vars['t']=null; }
   else
-    vars['t']=map.getCurrentMapType().getUrlArg();
+    vars['t']=map.getMapTypeId();
 
   var url = document.location.protocol+'//'+document.location.hostname+document.location.pathname;
@@ -50,28 +46,29 @@
 };
 
-PageLinker.url2Map = function( map )
+PageLinker.url2Map = function( mapOptions )
 {
   var vars = PageLinker.getQueryVars();
   if ( !( (vars['z'] && vars['ll']) || vars['t'] ) )
-    return;
+    return false;
 
-  var mapType = G_NORMAL_MAP;
+  var mapType = google.maps.MapTypeId.ROADMAP;
   if  (vars['t'])
   for (var i=0; i<map.getMapTypes().length; i++)
     if ( map.getMapTypes()[i].getUrlArg()==vars['t'] )
     {
-      mapType = map.getMapTypes()[i];break;
+      mapOptions.mapTypeId = map.getMapTypes()[i];break;
     }
   
   if (vars['z'] && vars['ll'])
   {
-    var zoom = parseFloat(vars['z']);
+    mapOptions.zoom = parseFloat(vars['z']);
     var ll = vars['ll'].split( "," );
     if (ll.length==2)
     {
-      var center = new google.maps.LatLng( ll[0], ll[1] );
-      map.setCenter( center, zoom, mapType );
+      mapOptions.center = new google.maps.LatLng( ll[0], ll[1] );
     }
+    return true;
   }
+  return false;
 }
 
