Uploaded image for project: 'Appcelerator - INBOX'
  1. Appcelerator - INBOX
  2. AC-2914

Android: Views added to a Map View can't be seen

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Invalid
    • Affects Version/s: None
    • Component/s: Titanium SDK & CLI
    • Environment:
      • Android 2.2 Google APIs emulator
      • Titanium Mobile SDK 2.1.0.GA
      • Titanium Studio 2.1.0.201206251749

      Description

      Problem

      If you attempt to add any view to a Map View, the added view will not appear. As Titanium.Map.View decends from Titanium.UI.View, you should be able to add any view you want to (on top of) a Map View.

      Expected behavior

      A red square should appear in the bottom left corner of the map.

      Actual behavior

      The red square does not appear at all.

      Testcase

      Paste the following code into a new project's app.js file and run it using the Android 2.2 Google APIs emulator.

      If you change "Ti.Map.createView" to Ti.UI.createView", the red square appears correctly.

      app.js

      var win1 = Ti.UI.createWindow({
        backgroundColor:'#fff',
        exitOnClose:true,
        navBarHidden:true,
        layout:'vertical'
      });
       
      var map1=Ti.Map.createView({
                    mapType:Ti.Map.STANDARD_TYPE,
                    animate:true,
                    region:{latitude:37.423156, longitude:-122.084917,
                            latitudeDelta:0.01, longitudeDelta:0.01},
                    regionFit:true,
                    annotations:[Ti.Map.createAnnotation({
                                   latitude:37.423156,
                                   longitude:-122.084917,
                                   image:'/images/MapPin.png'
                                 })],
                    userLocation:true,
                    height:Ti.UI.Fill
                  });
      win1.add(map1);
       
      var square1=Ti.UI.createView({
                    height:20,
                    width:20,
                    backgroundColor:'red',
                    bottom:10,
                    left:10
                  });
      map1.add(square1);
       
      win1.open();
      

      Solution/Fix

      app.js

      var win1 = Ti.UI.createWindow({
      	backgroundColor : '#fff',
      	exitOnClose : true,
      	navBarHidden : true,
      	//layout : 'vertical'
      });
       
      var map1 = Ti.Map.createView({
      	mapType : Ti.Map.STANDARD_TYPE,
      	animate : true,
      	region : {
      		latitude : 37.423156,
      		longitude : -122.084917,
      		latitudeDelta : 0.01,
      		longitudeDelta : 0.01
      	},
      	regionFit : true,
      	annotations : [Ti.Map.createAnnotation({
      		latitude : 37.423156,
      		longitude : -122.084917,
      		image : '/images/MapPin.png'
      	})],
      	userLocation : true,
      	height : Ti.UI.Fill
      });
      win1.add(map1);
       
      var square1 = Ti.UI.createView({
      	height : 20,
      	width : 20,
      	backgroundColor : 'red',
      	bottom : 10,
      	left : 10,
      	//zIndex: 1
      });
      win1.add(square1);
       
      win1.open(); 
      

      View Based Solution

      app.js

      var win1 = Ti.UI.createWindow({
      	backgroundColor : '#fff',
      	exitOnClose : true,
      	navBarHidden : true,
      	//layout : 'vertical'
      });
       
      var viewbot = Ti.UI.createView({
      	
      });
       
      win1.add(viewbot);
       
      var map1 = Ti.Map.createView({
      	mapType : Ti.Map.STANDARD_TYPE,
      	animate : true,
      	region : {
      		latitude : 37.423156,
      		longitude : -122.084917,
      		latitudeDelta : 0.01,
      		longitudeDelta : 0.01
      	},
      	regionFit : true,
      	annotations : [Ti.Map.createAnnotation({
      		latitude : 37.423156,
      		longitude : -122.084917,
      		image : '/images/MapPin.png'
      	})],
      	userLocation : true,
      	height : Ti.UI.Fill
      });
      viewbot.add(map1);
       
      var square1 = Ti.UI.createView({
      	height : 20,
      	width : 20,
      	backgroundColor : 'red',
      	bottom : 10,
      	left : 10,
      	//zIndex: 1
      });
      viewbot.add(square1);
       
      win1.open(); 
      

        Attachments

          Activity

            People

            • Assignee:
              clathrop Carter Lathrop
              Reporter:
              bitshftr Shawn Lipscomb
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Git Integration