Hello such everyone, I have a problem: I'm working with googlemap, call the MARKERS from a Json, until then everything I works well, so do not make is that once I load the markers, which make screen zoom to the region of the markers.
PD I think that in HTML you can do this with the function BOUNDS:
fitBounds
We adjust the zoom of the page according to the number of registered bookmarks
My code is as follows:
var url = "http://fotoalquileres.com/data_jquery_movil.php"; var json,i; var annotations = new Array() var win = Titanium.UI.createWindow(); var cabeza = Ti.UI.createView({ backgroundGradient: { type: 'linear', startPoint: { x: '0', y: '0' }, endPoint: { x: '0', y: '100%' }, colors: [ { color: '#454545', offset: 0.0}, { color: '#2B2B2B', offset: 1 }], }, height : '50dp', top:0, zIndex: 1 }); var logo = Ti.UI.createImageView({ top:0, left:0, image:'images/logo_fotoalquileres.png' }); cabeza.add(logo); var xhr = Ti.Network.createHTTPClient({ onload: function() { json = JSON.parse(this.responseText); for (i = 0; i < json.length; i++) { annotations[i] =Ti.Map.createAnnotation({ latitude:json[i].LATITUD, longitude:json[i].LONGITUD, title: json[i].TIPO, subtitle: json[i].PRECIO, animate: true, image: 'http://www.fotoalquileres.com/marker.png' }) mapview.addAnnotation(annotations[i]); } mapview.setRegionFit(true); }, onerror: function(e) { Ti.API.debug("STATUS: " + this.status); Ti.API.debug("TEXT: " + this.responseText); Ti.API.debug("ERROR: " + e.error); alert('There was an error retrieving the remote data. Try again.'); } }); xhr.open("GET", url); xhr.send(); var mapview = Titanium.Map.createView({ mapType: Titanium.Map.STANDARD_TYPE, region: {latitude:40.46366700000001, longitude:-3.7492200000000366, latitudeDelta:0.5, longitudeDelta:0.5}, animate:true, regionFit:true, userLocation:true }); win.add(cabeza); win.add(mapview); win.open();
Texto Orginal: Hola que tal a todos, tengo un problema: Estoy trabajando con googlemap, llamo a los MARKERS desde un Json, hasta ahí todo me funciona bien, lo que no se hacer es que una vez que me cargue los marcadores, que la pantalla haga un zoom a la region de los markers.
PD Creo que en HTML se puede hacer esto con los BOUNDS con la funcion:
fitBounds
Ajustamos el zoom de la pagina de acuerdo a la cantidad de marcadores registrados
Mi código es el siguiente: