# Visual Basic > Visual Basic 6 and Earlier >  google maps + vb6 + webview2 rc6

## jefersonob

Hello, as most of you know, google maps api in version 3.48 has dropped compatibility with internet explorer.

I'm trying to use a solution made of olaf, the vbRichClient library that RC6 uses with webview2 based on chromium.

I am trying to capture the coordinates of the marker that I move through the google maps API.

I have the following html file that I do pull up via
WV.Navigate App.Path & "\mapa.html"



```
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0}
      #map_canvas { height: 100% }
    </style>
   <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3.47&key=yourkeys"></script>
    <script type="text/javascript">
		var map 
		var marker
		var sURL 
		var ObjParent;

		function initialize(Lat, Lng) {
			var latlng = new google.maps.LatLng( Lat, Lng);

			var mapOptions = {
			  center: latlng,
			  zoom: 17,
			  mapTypeId: google.maps.MapTypeId.HYBRID
			};
			map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
			marker = new google.maps.Marker({
				position: latlng, 
				draggable:true,
				map: map,
				title:"Arrastra para selecionar un lugar"
			});   

			sURL = "http://maps.google.com/maps?f=q&q=" + Lat + "," + Lng + "&t=h"

			google.maps.event.addListener(marker, 'click', function() {window.open(sURL);});
			
			google.maps.event.addListener(marker, "dragend", function(event) {

				var point = marker.getPosition();
				map.panTo(point);
				ObjParent.MapsMarkerEvent(point.lat(),point.lng());
				sURL = "http://maps.google.com/maps?f=q&q=" + point.lat() + "," + point.lng() + "&t=h"
			});		
		}

		function show_position(Lat, Lng){
			var pos=new google.maps.LatLng(Lat, Lng);
			map.setCenter(pos);			
			marker.setPosition(pos);
			marker.setMap(map);
			marker.setTitle("Lugar donde se hizo la foto");
			sURL = "http://maps.google.com/maps?f=q&q=" + Lat + "," + Lng + "&t=h"
		}
	
    </script>
  </head>
  <body scroll="no" onload="initialize(0, 0)">
    <div id="map_canvas" style="width:100%; height:100%"></div>
  </body>
</html>
```

my load is



```
Private Sub Form_Load()
  Visible = True 
  Set WV = New_c.WebView2 

  If WV.BindTo(picWV.hWnd) = 0 Then MsgBox "couldn't initialize WebView-Binding": Exit Sub
  
  WV.AddScriptToExecuteOnDocumentCreated "function Initialize(){ vbH().RaiseMessageEvent('map_canvas','') }"
  
  WV.Navigate App.Path & "\mapa.html"
End Sub
```

The show_position function works perfectly


```
WV.jsRunAsync "show_position", "your_lat", "your_long"
```

In my debug, at the moment the browser load is complete, no information appears, I need to bring the latitude and longitude as well as I move the cursor on the map.



```
Private Sub WV_DocumentComplete()
  Debug.Print "WV_DocumentComplete"
  
  Debug.Print WV.jsRun("Initialize") 'no have result
End Sub
```

could you please help me correct my code.

----------


## Schmidt

> The show_position function works perfectly
> 
> 
> ```
> WV.jsRunAsync "show_position", "your_lat", "your_long"
> ```


If that works fine already - then I'd slowly "go from there" in your coding.

Your current: 
WV.AddScriptToExecuteOnDocumentCreated "function Initialize()..."
in the VB6-code-parts, does not have any real functionality as it is - and is not really needed.

Your successfully VB6-callable "show_position" function is part of your html-files js-script-sections - 
and since it works, I'd just include a few more js-helper-functions directly in that html-file.

Also, ... as it is currently... you have only a *single* "marker" js-object in your js-code
and can thus interact from VB6 only with that single marker-object.

If you want more than a single Marker on that google-map, you will have to restructure your js-Code first.

Also your "show_position" is currently not properly named IMO ...
(since it *changes* the marker-position to the new passed Lat/Lng coord ... prior to showing the marker).

In that vein, make the Google-maps-js-object-model a bit more "accessible" from the outside (from VB6),
by adding "better speaking helper-functions" like:
- addMarker(MKey, Title, Lat, Lng) ... using a "var marker*s* = {}" js-Object-variable at the js-side
..(to store the new added marker under the given Key as a new Property of that marker*s*-object-collection)
- removeMarker(MKey)
- setMarkerPosition(MKey, Lat, Lng)
- getMarkerPosition(MKey)
- showMarkerInCenterOfMap(MKey)

... a.s.o.

Only *after* that is solved -
(e.g. you being successful in building most of the above mentioned functions,
to successfully create and interact with more than a single marker) - 
should we talk about "Event-interaction with VB6"
(e.g. when such a Marker gets dragged within the WebView2 on the google-map)

HTH

Olaf

----------

