Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8489] Android: Map - selectAnnotation method is not functioning properly when passed an annotation

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2017-07-27T21:12:33.000+0000
Affected Version/sRelease 2.0.0, Release 3.1.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterMichael Pettiford
AssigneeEric Merriman
Created2012-04-02T13:05:37.000+0000
Updated2017-07-27T21:12:33.000+0000

Description

Steps to reproduce 1. Create a sample app and change the app.js code to the following

var _window = Ti.UI.createWindow();
_window.open();

var locations = '{"pois":[' + '{"city":"Cupertino","latitude":"37.3230144444444","longitude":"-122.01909"},' + '{"city":"San Jose","latitude":"37.2599948914071","longitude":"-121.876229713452"},' + '{"city":"Mountain View","latitude":"37.4040712","longitude":"-122.1119444"},' + '{"city":"Fremont","latitude":"37.5022995952419","longitude":"-121.974959595242"},' + '{"city":"Redwood City","latitude":"37.4914862206843","longitude":"-122.223387131433"},' + '{"city":"Morgan Hill","latitude":"37.1130658823529","longitude":"-121.642779411765"},' + '{"city":"Hayward","latitude":"37.6529567785235","longitude":"-122.110047315436"},' + '{"city":"San Mateo","latitude":"37.5488359183673","longitude":"-122.310417142857"},' + '{"city":"Livermore","latitude":"37.6834371717172","longitude":"-121.776987575758"},' + '{"city":"Dublin","latitude":"37.7067795513183","longitude":"-121.928981405136"},' + '{"city":"Colma","latitude":"37.67668","longitude":"-122.467328319902"},' + '{"city":"El Cerrito","latitude":"37.89991","longitude":"-122.29843"},' + '{"city":"Concord","latitude":"37.9726973693895","longitude":"-122.042295983774"},' + '{"city":"Pittsburg","latitude":"38.0060320288764","longitude":"-121.835960060159"},' + '{"city":"Manteca","latitude":"37.7863470369327","longitude":"-121.254679292344"},' + '{"city":"Corte Madera","latitude":"37.9373022828566","longitude":"-122.518824122653"},' + '{"city":"Modesto","latitude":"37.6891241935484","longitude":"-120.99570516129"},' + '{"city":"Stockton","latitude":"38.056463822656","longitude":"-121.376204288256"},' + '{"city":"Vacaville","latitude":"38.3629562189087","longitude":"-121.964531681599"},' + '{"city":"Merced","latitude":"37.3196871717172","longitude":"-120.490417878788"}' + ']}';
		var json = JSON.parse(locations);

		var mapView = Ti.Map.createView({
			mapType : Titanium.Map.STANDARD_TYPE,
			animate : true,
			regionFit : true,
			userLocation : true
		});
		_window.add(mapView);

		var tableView = Ti.UI.createTableView({
			right : 0,
			width : 150,
			backgroundColor: 'white'
		});
		tableView.addEventListener('click', function(e) {
			var toClick = mapView.annotations[e.source.index];
			mapView.selectAnnotation(toClick);
		})

		_window.add(tableView);

		function createTableViewRows(json) {
			var rows = [];

			if(json.pois) {
				var length = json.pois.length;
				for(var i = 0; i < length; i++) {

					var poi = json.pois[i];
					rows.push({
						latitude : poi.latitude,
						longitude : poi.longitude,
						title : poi.city,
						storeData : poi,
						index : i,
					});
				}
			}

			return rows;
		}

		function createAnnotations(json) {
			var annotations = [];

			if(json.pois) {
				var length = json.pois.length;
				for(var i = 0; i < length; i++) {

					var poi = json.pois[i];
					annotations.push(Ti.Map.createAnnotation({
						latitude : poi.latitude,
						longitude : poi.longitude,
						title : poi.city,
						subtitle : poi.address1,
						pincolor : Titanium.Map.ANNOTATION_RED,
						storeData : poi,
					}));
				}
			}

			return annotations;
		}

		function load() {
			tableView.data = createTableViewRows(json);
			mapView.annotations = createAnnotations(json);
		}

		load();
2. Press a row in the table view Actual result: The annotation is not selected *Note* I tried logging the value of toClick and undefined was returned Expected result: An annotation is selected *Note it might be the annotation of the selected row*

Comments

  1. jithinpv 2013-03-13

    Issue reproduces with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4
  2. Lee Morris 2017-07-27

    Closing due to inactivity. If this issue still exists, please raise a new ticket.

JSON Source