Hello, create an apps which submits the latitude and longitude to a HTML file that connects to Google Maps. The position is shown in the HTML with a circle of diameter of 2.5 km. This runs perfectly on the emulator but when passing it to my Bold does not display the map. The same happens in a cell phone Torch.
Thanks.
private void mostrarMapa(final Dialog progreso) {
final Form mapa = new Form("Mapa de Localización");
mapa.setLayout(new BorderLayout());
mapa.setScrollable(false);
try {
Location loc = LocationManager.getLocationManager().getCurrentLocation();
final Coord lastLocation = new Coord(loc.getLatitude(), loc.getLongtitude());
WebBrowser web = new WebBrowser(){
@Override
public void onLoad(String url) {
Component c = getInternal();
if(c instanceof BrowserComponent) {
BrowserComponent b = (BrowserComponent)c;
String mensaje = Double.toString(lastLocation.getLatitude()) + "," + Double.toString(lastLocation.getLongitude());
b.execute("mapa('" + mensaje + "')");
}
} };
mapa.addComponent(BorderLayout.CENTER, web);
web.setURL("jar:///mapa.html");
} catch (IOException ex) {
Dialog.show("Error", ex.getMessage(), "Ok", null);
// Logger.getLogger(IdentificaPosicion.class.getName()).log(Level.SEVERE, null, ex);
}
progreso.dispose();
mapa.show();
}
// Pase de parametros de app a html
function mapa(mensaje) {
var punto = mensaje.split(",");
rutaMarcas();
map.setCenter(new google.maps.LatLng(punto[0], punto[1]));
adicionMarca('Usted esta aquí',new google.maps.LatLng(punto[0], punto[1]),EJE);
marcaCirculo(new google.maps.LatLng(punto[0], punto[1]));
// map.setZoom(zoom);
}
// Pon Marcas dentro de los poligonos que son parte de la ruta
function rutaMarcas() {
// Inicia eliminando las rutas si existen
eliminaMarcas();
for ( var x = 0; x < puntos.length; x++) {
var punto = puntos[x].split(",");
adicionMarca(punto[0],new google.maps.LatLng(punto[1], punto[2]),PTO)
}
}
// Adiciona una marca al mapa y empujalo al arreglo.
function adicionMarca(nombre,localizacion,tipo) {
if (tipo == PTO){
var marca = new google.maps.Marker({
position: localizacion,
title: nombre,
map: map
});
} else {
var marca = new google.maps.Marker({
position: localizacion,
title: nombre,
map: map
});
}
marcas.push(marca);
}
// Elimina todas las marcas en el arreglo y remueve las referencias a el
function eliminaMarcas() {
if (marcas) {
for (i in marcas) {
marcas[i].setMap(null);
}
marcas.length = 0;
}
}
// Funcion que permite Dibujar un circulo al rededor del punto donde se encuentre el usuario
function marcaCirculo(latLng) {
var circulo = {
strokeColor: "red", // "#008888", // Color del borde del círculo
strokeOpacity: 0.6, // opacidad dl borde (entre 9,9 y 1)
strokeWeight: 2, // ancho del borde en px
fillColor: "yellow", // "#880088", // Color del relleno
fillOpacity: 0.4, // Opacidad del relleno
geodesic: true, // gedodésica sobre la Tierra (por defecto es false)
map: map, // El mapa con el que estamos trabajando
center: latLng, // En este caso el mismo que nuestro marcador
radius: 2574.95 // Radio del círculo (correspondiente a metros) La conversion se base en la siguiente fórmula: 1 metro equivale a 0.000621371192 millas (1 m. = 0.000621371192 milla)
};
cityCircle = new google.maps.Circle(circulo);
}