Finally, I found what was wrong with the code! In VB, there is a subroutine that generates some parts of javascript code, especifycally two variables called "puntos" and "puntos2". On the original post I simplified the javascript code for better reading, thinking that this code was fine...
The "puntos2" variable have and extra comma at the end, and this extra comma was blocking the window.external process.
So, the final javascript code is this:
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Poligonal - Vista previa</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</meta></meta></head>
<body>
<div id="map"></div>
<script type="text/javascript">
var latitud
var longitud
var latylong
function coordGoogle(str) {
window.external.coordGoogle(str);
}
function Map_Click(e){
latitud = e.latLng.lat();
longitud = e.latLng.lng();
latylong = latitud + " " + longitud;
coordGoogle(latylong);
}
function initMap() {
var bounds = new google.maps.LatLngBounds();
bounds.extend(new google.maps.LatLng(-57.9273407169989, -34.9455780254582));
bounds.extend(new google.maps.LatLng(-57.9280791179909, -34.9463018545704));
var nuevoZoom = getBoundsZoomLevel(bounds, 630, 740);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: nuevoZoom,
tilt: 0,
mapTypeId: "hybrid",
center: {lat: -34.945932129038, lng: -57.9277009575209 }
});
setMarkers(map);
setMarkers2(map);
google.maps.event.addListener(map, 'click', Map_Click);
}
var puntos = [["E1", -34.9456863703928, -57.9279809728952, 0],["E2", -34.9455780254582, -57.9276547821795, 1],["E3", -34.9461597123083, -57.9273407169989, 2],["E4", -34.9463018545704, -57.9275503647045, 3],["E5", -34.9459350794102, -57.9279876151491, 4],["E1'", -34.9457038384157, -57.9280344515735, 5]];
var puntos2 = [["1", -34.9458646104288, -57.9277684856222, 1],["2", -34.9458301555346, -57.9276848953222, 2],["3", -34.9456424949709, -57.9278302365446, 3],["4", -34.9456477344085, -57.9277152389542, 5],["5", -34.945722286851, -57.9276564071297, 6],["6", -34.9457875635967, -57.927589118614, 7],["7", -34.9460946833933, -57.9274513093932, 9],["8", -34.9461634761396, -57.9273884621752, 10],["9", -34.9461678758456, -57.9274442738932, 11],["11", -34.9462280721616, -57.9274975162208, 13],["12", -34.9459700858821, -57.9276543326257, 14],["22", -34.9462239845672, -57.927710713715, 15],["14", -34.9459218009585, -57.9278793037058, 17],["15", -34.9459862149622, -57.9278217925306, 18],["17", -34.9459587895424, -57.9280791179909, 19]];
function getBoundsZoomLevel(bounds, mapHeight, mapWidth) {
var WORLD_DIM = { height: 256, width: 256 };
var ZOOM_MAX = 21;
function latRad(lat) {
var sin = Math.sin(lat * Math.PI / 180);
var radX2 = Math.log((1 + sin) / (1 - sin)) / 2;
return Math.max(Math.min(radX2, Math.PI), -Math.PI) / 2;
}
function zoom(mapPx, worldPx, fraction) {
return Math.floor(Math.log(mapPx / worldPx / fraction) / Math.LN2);
}
var ne = bounds.getNorthEast();
var sw = bounds.getSouthWest();
var latFraction = (latRad(ne.lat()) - latRad(sw.lat())) / Math.PI;
var lngDiff = ne.lng() - sw.lng();
var lngFraction = ((lngDiff < 0) ? (lngDiff + 360) : lngDiff) / 360;
var latZoom = zoom(mapHeight, WORLD_DIM.height, latFraction);
var lngZoom = zoom(mapWidth, WORLD_DIM.width, lngFraction);
return Math.min(latZoom, lngZoom, ZOOM_MAX);
}
function setMarkers(map) {
for (var i = 0; i < puntos.length; i++) {
var punto = puntos[i];
var marker = new google.maps.Marker({
position: { lat: punto[1], lng: punto[2] },
map: map,
icon: new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=" + punto[0] + "|FC6254|000000"),
title: punto[0],
zIndex: punto[3]
});
}
}
function setMarkers2(map) {
for (var i = 0; i < puntos2.length; i++) {
var punto = puntos2[i];
var marker = new google.maps.Marker({
position: { lat: punto[1], lng: punto[2] },
map: map,
icon: new google.maps.MarkerImage("http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png"),
title: punto[0],
zIndex: punto[3]
});
}
}
</script>
<script async="" mode="hold" /> src="https://maps.googleapis.com/maps/api/js?signed_in=true&callback=initMap">
</body>
</html>
The end of "puntos2" was like "....19],];" and now is "....19]];". I feel so stupid. And sorry for waste your time!
Thanks
joaco