hansemannn / titanium-googlemaps

🗺 Use the Google Maps SDK in Titanium
Other
87 stars 26 forks source link

mapView.region is not updated when moving camera #64

Closed bitfabrikken closed 7 years ago

bitfabrikken commented 7 years ago

Not sure this is a bug or if it's meant to be doing this, but looking at ti.map, the map.region.latitude and .longitude parameters, are updated when you move the camera around. Not the case here, as seen in the following example:

var win = Ti.UI.createWindow({});
win.open();

var maps = require("ti.googlemaps");
maps.setAPIKey("<YOUR_GOOGLE_MAPS_API_KEY>");

var mapView = maps.createView({
    mapType: maps.MAP_TYPE_TERRAIN,
    indoorEnabled: true,
    indoorPicker: false,
    compassButton: true,
    myLocationButton: true,
    myLocationEnabled: true,
    region: {
        latitude: 37.368122,
        longitude: -121.913653,
        zoom: 0
    }
});
win.add(mapView);

mapView.addEventListener("regionchanged", function(e){

    /*
    //hackish fix
    mapView.region = {
        latitude: e.latitude,
        longitude: e.longitude,
        zoom: (mapView.region.zoom) ? mapView.region.zoom : undefined  
    };
    */

    console.log("regionchanged, latitude: "+e.latitude+", longitude: "+e.longitude);
    console.log("mapView.region is: ", mapView.region);
    //console.log(mapView.region);
    console.log("the above latitude and longitude should match");

});
hansemannn commented 7 years ago

I think the region property will always reflect the location of the map when it has been created. I'd need to do some debugging to find out the actual values.

hansemannn commented 7 years ago

Just fixed the issue in https://github.com/hansemannn/ti.googlemaps/commit/a98803459bcdc8e22f33d6de4f4c1720e3cc87bb. Guess I'll do a 2.6.3, but it would be great if you could test it before. Or @yozef if that's possible, you also know how to build.

bitfabrikken commented 7 years ago

Will test in 9 hours time when I get to my office, thanks :)

bitfabrikken commented 7 years ago

Works perfectly with bearing, zoom, viewingAngle, latitude and longitude :)

hansemannn commented 7 years ago

https://github.com/hansemannn/ti.googlemaps/releases/tag/v2.6.2