Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

ti.map - regionChanged event not firing on Android

$
0
0

I am writing an app that relies on the ti.map regionChanged event. The app works fine on ios, but on Android the regionChanged event is never fired. I am sure that all the permissions and key are set up correctly as the map displays fine and all annotations and routes are working ok.

As the app was using a large number of annotations and routes I wrote a test app that simply displays a map and a label that should show the current region when the regionChanged event is fired and even that does not work.

I have tried the ti.map version 2.2.3 that ships with sdk 3.5.0.GA and also 1.2.4 (the oldest version installed on my mac) and 2.2.5 from github, all behave the same.

Any advice would be very gratefully accepted.

Set up as follows:

Mac OSX Yosemite 10.10.2 Titanium Studio 3.4.1 Mobile SDK 3.5.0.GA

Tested on Samsung Galaxy Tab 10.1 and Samsung Galaxy Note 3

Tiapp.xml

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <id>com.phc.test2</id>
    <name>Test2</name>
    <version>1.0</version>
    <publisher>Des</publisher>
    <url>http://</url>
    <description/>
    <copyright>2015 by Des</copyright>
    <icon>appicon.png</icon>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>true</analytics>
    <guid>0f7699d8-23b5-4063-905d-ee2521f21f3b</guid>
    <property name="ti.ui.defaultunit" type="string">dp</property>
    <ios>
        <plist>
            <dict>
                <key>UISupportedInterfaceOrientations~iphone</key>
                <array>
                    <string>UIInterfaceOrientationPortrait</string>
                </array>
                <key>UISupportedInterfaceOrientations~ipad</key>
                <array>
                    <string>UIInterfaceOrientationPortrait</string>
                    <string>UIInterfaceOrientationPortraitUpsideDown</string>
                    <string>UIInterfaceOrientationLandscapeLeft</string>
                    <string>UIInterfaceOrientationLandscapeRight</string>
                </array>
                <key>UIRequiresPersistentWiFi</key>
                <false/>
                <key>UIPrerenderedIcon</key>
                <false/>
                <key>UIStatusBarHidden</key>
                <false/>
                <key>UIStatusBarStyle</key>
                <string>UIStatusBarStyleDefault</string>
            </dict>
        </plist>
    </ios>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
            <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
            <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
            <uses-permission android:name="com.phc.test2.permission.MAPS_RECEIVE"/>
            <permission
                android:name="com.phc.test2.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
            <application>
                <meta-data
                    android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyAc6Ap2SmzWB1ZJm7cbGdu_Kxb3ByaHvsM"/>
            </application>
        </manifest>
    </android>
    <mobileweb>
        <precache/>
        <splash>
            <enabled>true</enabled>
            <inline-css-images>true</inline-css-images>
        </splash>
        <theme>default</theme>
    </mobileweb>
    <modules>
        <module platform="iphone">ti.map</module>
        <module platform="android">ti.map</module>
    </modules>
    <deployment-targets>
        <target device="android">true</target>
        <target device="blackberry">false</target>
        <target device="ipad">false</target>
        <target device="iphone">false</target>
        <target device="mobileweb">false</target>
    </deployment-targets>
    <sdk-version>3.5.0.GA</sdk-version>
</ti:app>
app.js
var win1 = Titanium.UI.createWindow({
    orientationModes:[Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT],
    url:'home.js',
    exitOnClose:true,
    navBarHidden:true,
    title:'Test2'
});
 
win1.open();
home.js
var win = Titanium.UI.currentWindow;
var MapModule = require('ti.map');
 
if (Ti.Platform.name == 'android') {
    var rc = MapModule.isGooglePlayServicesAvailable();
    switch (rc) {
        case MapModule.SUCCESS:
            Ti.API.info('Google Play services is installed.');
            break;
        case MapModule.SERVICE_MISSING:
            alert('Google Play services is missing. Please install Google Play services from the Google Play store.');
            break;
        case MapModule.SERVICE_VERSION_UPDATE_REQUIRED:
            alert('Google Play services is out of date. Please update Google Play services.');
            break;
        case MapModule.SERVICE_DISABLED:
            alert('Google Play services is disabled. Please enable Google Play services.');
            break;
        case MapModule.SERVICE_INVALID:
            alert('Google Play services cannot be authenticated. Reinstall Google Play services.');
            break;
        default:
            alert('Unknown error.');
            break;
    }
}
 
var mapView = MapModule.createView({
    mapType: MapModule.NORMAL_TYPE,
    region: {latitude:50.96, longitude:0.28, latitudeDelta:1.15, longitudeDelta:1.15},
    animate:false,
    userLocation:true
});
 
var l1 = Ti.UI.createLabel({
    text: "It's Poo",
    color: '#000000',
    backgroundColor: '#ffffff',
    textAlign:'center',
    top:0,
    left:0,
    width:'100%',
    height:'20%',
    font:{fontSize:16},
    opacity: 0.75
});
 
win.add(mapView);
win.add(l1);
 
mapView.addEventListener('regionChanged', function(e) {
    win.remove(l1);
    l1.text = JSON.stringify(e);
    win.add(l1);
});

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>