Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13750] Android: Google Map v2 Module - Current Location button doesn't work. Nothing happened.

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2017-07-21T05:38:48.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, mapv2
ReporterJong Eun Lee
AssigneeEric Merriman
Created2013-04-28T15:24:57.000+0000
Updated2017-07-21T05:38:53.000+0000

Description

[Android Google Map v2 Module https://github.com/appcelerator/titanium_modules/tree/master/map]. If I use the Run command from Studio to build and example application for an Android Device, Current Location button doesn't work. Nothing happened. expected result : After touch current location button on right top map, we can see current position on the map. tested source (example/app.js in module):

var MapModule = require('ti.map');



var win = Ti.UI.createWindow();
var table = Ti.UI.createTableView();
var tableData = [];

var multiMapRow = Ti.UI.createTableViewRow({title: 'Multi Map'});
tableData.push(multiMapRow);
multiMapRow.addEventListener('click', function(e) {
   multiMapTest();
});


var annotationRow = Ti.UI.createTableViewRow({title:'AnnotationTest'});
tableData.push(annotationRow);
annotationRow.addEventListener('click', function(e) {
   annotationTest();
});


var routeRow = Ti.UI.createTableViewRow({title:'Routes Test'});
tableData.push(routeRow);
routeRow.addEventListener('click', function(e) {
   routeTest();
});


table.setData(tableData);
win.add(table);
win.open();




/************************************************************************************/
/************************************************************************************/
									//Multi Maps
/************************************************************************************/
function multiMapTest() {
var win = Ti.UI.createWindow({fullscreen: false});

var map1 = MapModule.createView({
	userLocation: true,
	mapType: MapModule.NORMAL_TYPE,
	animate: true,
	region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 }, //Sydney
	height: '50%',
	top: 0,
	left: 0,
	width: '50%'
});
var map2 = MapModule.createView({
	userLocation: true,
	mapType: MapModule.NORMAL_TYPE,
	animate: true,
	region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 }, //Sydney
	height: '50%',
	top: 0,
	right: 0,
	width: '50%'
});
var map3 = MapModule.createView({
	userLocation: true,
	mapType: MapModule.NORMAL_TYPE,
	animate: true,
	region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 }, //Sydney
	height: '50%',
	bottom: 0,
	left: 0,
	width: '50%'
});
var map4 = MapModule.createView({
	userLocation: true,
	mapType: MapModule.NORMAL_TYPE,
	animate: true,
	region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 }, //Sydney
	height: '50%',
	bottom: 0,
	right: 0,
	width: '50%'
});

win.add(map1);
win.add(map2);
win.add(map3);
win.add(map4);
win.open();
}


/************************************************************************************/
/************************************************************************************/
									//ANNOTATIONS
/************************************************************************************/
function annotationTest() {
var win = Ti.UI.createWindow({fullscreen: false});
var anno = MapModule.createAnnotation({latitude: -33.87365, image: 'map_pin.png', longitude: 151.20689, title: "Sydney", subtitle: "Sydney is quite chill", draggable: true});
var anno2 = MapModule.createAnnotation({latitude: -33.86365, pincolor: MapModule.ANNOTATION_BLUE, longitude: 151.21689, title: "Anno2", subtitle: "This is anno2", draggable: true});
var anno3 = MapModule.createAnnotation({latitude: -33.85365, longitude: 151.20689, title: "Anno3", subtitle: "This is anno3", draggable: false});
var anno4 = MapModule.createAnnotation({latitude: -33.86365, longitude: 151.22689, title: "Anno4", subtitle: "This is anno4", draggable: true});

Ti.API.info ("Latitude:" + anno.latitude);
Ti.API.info ("Title:" + anno.title);

var map = MapModule.createView({
	userLocation: true,
	mapType: MapModule.NORMAL_TYPE,
	animate: true,
	annotations: [anno, anno2, anno4],
	region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 }, //Sydney
	top: '30%'
});
Ti.API.info("userLocation: " + map.userLocation);
win.add(map);

map.addEventListener('click', function(e) {
	Ti.API.info("Latitude: " + e.latitude);
	Ti.API.info("Source: " + e.clicksource);
});
var button = Ti.UI.createButton({top: 0, left: 0, title: "Go Mt. View"});
button.addEventListener('click', function(e) {
	map.region = {latitude: 37.3689, longitude: -122.0353, latitudeDelta: 0.1, longitudeDelta: 0.1 }; //Mountain View
});

var button2 = Ti.UI.createButton({top: 0, right: 0, title: "add anno3"});
button2.addEventListener('click', function(e) {
	map.addAnnotation(anno3);
});

var button3 = Ti.UI.createButton({top: 0, title: "rm anno3"});
button3.addEventListener('click', function(e) {
	map.removeAnnotation(anno3);
});

var button4 = Ti.UI.createButton({top: '10%', title: "rm all"});
button4.addEventListener('click', function(e) {
	map.removeAllAnnotations();
});

var button5 = Ti.UI.createButton({top: '10%', left: 0, title: "remove annos"});
button5.addEventListener('click', function(e) {
	Ti.API.info(anno.getTitle());
	map.removeAnnotations(["Sydney", anno2]);
});

var button6 = Ti.UI.createButton({top: '10%', right: 0, title: "select anno2"});
button6.addEventListener('click', function(e) {
	map.selectAnnotation(anno2);
});

var button7 = Ti.UI.createButton({top: '20%', left: 0, title: "desel anno2"});
button7.addEventListener('click', function(e) {
	map.deselectAnnotation(anno2);
});

var button8 = Ti.UI.createButton({top: '20%', right: 0, title: "modify anno2"});
button8.addEventListener('click', function(e) {
	anno2.title = "Hello";
	anno2.subtitle = "Hi there.";
	anno2.longitude = 151.27689;
});

win.add(button);
win.add(button2);
win.add(button3);
win.add(button4);
win.add(button5);
win.add(button6);
win.add(button7);
win.add(button8);
win.open();
}

/********************************************************************************/
							//Routes
/********************************************************************************/
function routeTest() {

var win = Ti.UI.createWindow({fullscreen: false});
var map = MapModule.createView({
	userLocation: true,
	mapType: MapModule.NORMAL_TYPE,
	animate: true,
	region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.02, longitudeDelta: 0.02 }, //Sydney
	top: '30%'
});
win.add(map);

var route1 = [{latitude: -33.87365, longitude: 151.20689}, {latitude: -33.87469, longitude: 151.20689}, {latitude: -33.87375, longitude: 151.20589}];
var route2 = [{latitude: -33.87565, longitude: 151.20789}, {latitude: -33.87469, longitude: 151.20689}, {latitude: -33.86375, longitude: 151.20589}];

var route = MapModule.createRoute({
    points: route1,
    color: "blue",
    width: 5.0
});

map.addRoute(route);

var button = Ti.UI.createButton({top: 0, left: 0, title: "+1 width"});
var w = 5.0;
button.addEventListener('click', function(e) {
	route.width = w + 1.0;
	w = w + 1.0;
});

var button2 = Ti.UI.createButton({top: 0, title: "change color"});
button2.addEventListener('click', function(e) {
	route.color = 'red';
});

var button3 = Ti.UI.createButton({top: 0, right: 0, title: "change routes"});
button3.addEventListener('click', function(e) {
	route.points = route2;
});

var button4 = Ti.UI.createButton({top: '10%', title: "remove route"});
button4.addEventListener('click', function(e) {
	map.removeRoute(route);
});

var button5 = Ti.UI.createButton({top: '10%', left: 0, title: "add route"});
button5.addEventListener('click', function(e) {
	map.addRoute(route);
});

win.add(button);
win.add(button2);
win.add(button3);
win.add(button4);
win.add(button5);
win.open();
}
tiapp.xml
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <id>net.codjong.sandbox</id>
    <name>Sandbox</name>
    <version>1.0</version>
    <publisher>yomybaby</publisher>
    <url>http://</url>
    <description>not specified</description>
    <copyright>2013 by yomybaby</copyright>
    <icon>appicon.png</icon>
    <persistent-wifi>false</persistent-wifi>
    <prerendered-icon>false</prerendered-icon>
    <statusbar-style>default</statusbar-style>
    <statusbar-hidden>false</statusbar-hidden>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>true</analytics>
    <guid>0f53e3ab-471e-4e0d-bf6a-34fdc57d108b</guid>
    <property name="ti.ui.defaultunit" type="string">system</property>
    <iphone>
        <orientations device="iphone">
            <orientation>Ti.UI.PORTRAIT</orientation>
        </orientations>
        <orientations device="ipad">
            <orientation>Ti.UI.PORTRAIT</orientation>
            <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
            <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
        </orientations>
    </iphone>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <!-- Allows the API to download data from Google Map servers -->
            <uses-permission android:name="android.permission.INTERNET"/>
            <!-- Allows the API to cache data -->
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
            <!-- Use GPS for device location -->
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
            <!-- Use Wi-Fi or mobile connection for device location -->
            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
            <!-- Allows the API to access Google web-based services -->
            <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
            <!-- Specify OpenGL ES 2.0 as a requirement -->
            <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
            <!-- Replace <com.domain.appid> with your application ID -->
            <uses-permission android:name="net.codjong.sandbox.permission.MAPS_RECEIVE"/>
            <permission
                android:name="net.codjong.sandbox.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
                
            
            <application>
                <!-- Replace "PASTE YOUR GOOGLE MAPS API KEY HERE" with the Google API key you obtained -->
                <!-- for my security, jus replace with ---- -->
                <meta-data
                    android:name="com.google.android.maps.v2.API_KEY" android:value="-----------"/>
            </application>
            
             
        </manifest>
    </android>
    <mobileweb>
        <precache/>
        <splash>
            <enabled>true</enabled>
            <inline-css-images>true</inline-css-images>
        </splash>
        <theme>default</theme>
    </mobileweb>
    <modules>
        <module platform="android">ti.map</module>
    </modules>
    <deployment-targets>
        <target device="blackberry">false</target>
        <target device="android">true</target>
        <target device="ipad">true</target>
        <target device="iphone">true</target>
        <target device="mobileweb">true</target>
        <target device="tizen">false</target>
    </deployment-targets>
    <sdk-version>3.1.0.GA</sdk-version>
</ti:app>

Comments

  1. Eduardo Gomez 2013-05-01

    JongEun Lee, Thanks for submit this report. What Android OS was this tested on? Just to make sure I'm on the same page: is the "Current Location button" the my-location button of a Map? e.g. http://developer.android.com/reference/com/google/android/gms/maps/UiSettings.html#isMyLocationButtonEnabled() It should be reproducible either MultiMap, AnnotationTest or Routes Test snippet but if you can confirm reproducible steps will be quicker to replicate on our end, thanks again.
  2. Jong Eun Lee 2013-05-02

    Hi Eduardo Gomez,

    Create New Mobile Project on Titanium Studio

    Select Classic templates, Single Window Application

    titanium SDK Version 3.1.0GA, app id : com.test.mapv2, click finish.

    Download ti.map-android-2.1.0.zip from https://github.com/appcelerator/titanium_modules/blob/master/map/mobile/android/dist/ti.map-android-2.1.0.zip

    copy zip file to Project Root

    edit tiapp.xml

       <android xmlns:android="http://schemas.android.com/apk/res/android">
           <manifest>
               <!-- Allows the API to download data from Google Map servers -->
               <uses-permission android:name="android.permission.INTERNET"/>
               <!-- Allows the API to cache data -->
               <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>  
               <!-- Use GPS for device location -->
               <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
               <!-- Use Wi-Fi or mobile connection for device location -->
               <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
               <!-- Allows the API to access Google web-based services -->
               <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
               <!-- Specify OpenGL ES 2.0 as a requirement -->
               <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
               <!-- Replace <com.domain.appid> with your application ID -->
               <uses-permission android:name="com.test.mapv2.permission.MAPS_RECEIVE"/>
               <permission android:name="com.test.mapv2.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
               <application>
                   <!-- Replace "PASTE YOUR GOOGLE MAPS API KEY HERE" with the Google API key you obtained -->
                   <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyArH9AKXlck-Mqpb75ibER2AqenPgxNoF8"/>
               </application>
           </manifest>
       </android>
       

    copy & past app.js from https://github.com/appcelerator/titanium_modules/blob/master/map/mobile/android/example/app.js to Resource folder.

    On Titanium Studio, click Run - android Device.

    *Result* Everything works except user-location(my location) Button. When I click location button on MultiMap, AnnotationTest or Routes Test snippe, nothing happened. Check this snapshot : http://cl.ly/image/2H3N292D2q2d Project Files : http://cl.ly/3a200y332O3j - Studio Preference Android SDK : Google API (Android 4.1.2) [armeabi-v7a] - Test Phone : Nexus S (4.1.1) I hope that this comment helps to fix problem. Thanks.
  3. Jong Eun Lee 2013-05-03

    Oops. It's work properly today. I don't know why. (I didn't build today. It's yesterday version. same phone, same app, same internet connection) :(
  4. Eric Merriman 2017-07-21

    Going to close this as unable to reproduce. If it still occurs, please reopen.

JSON Source