Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12810] Android: Maps V2 Module - Missing properties and methods from Ti.Map module

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-04-04T17:08:41.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.1.0, 2013 Sprint 07 API, 2013 Sprint 07
ComponentsAndroid
Labelsmapv2, parity, qe-testadded
ReporterBenjamin Hatfield
AssigneePing Wang
Created2013-02-21T20:24:13.000+0000
Updated2014-05-04T05:53:24.000+0000

Description

The following API items are not accessible by the Google Maps v2 module, but are available with the Ti.Map module. The View Class is missing the setLocation and zoom methods. * http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Map.View-method-setLocation * http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Map.View-method-zoom The Annotation class is missing the leftButton, leftView, rightButton, rightView, subtitleid and titleid properties.

Attachments

FileDateSize
applogo.png2013-03-29T22:11:15.000+00005574
face_happy.png2013-03-29T22:11:15.000+000037307
face_ok.png2013-03-29T22:11:15.000+000035114

Comments

  1. Ping Wang 2013-03-29

    Test case (the images are attached in the ticket):
       var MapModule = require('ti.map');
       
       var win = Ti.UI.createWindow({fullscreen: false, layout: "vertical"});
       var myView1 = Ti.UI.createView({
           width:Ti.UI.SIZE,
           height:Ti.UI.SIZE,
           backgroundColor:'red'
       });
        
       var label = Ti.UI.createLabel({
           text:" $400K ",
           font:{fontSize:30, fontWeight:"bold", fontStyle:"italic"}
       });
       
       myView1.add(label);
       
       
       var rightView = Ti.UI.createLabel({
           text:"LABEL"
       });
       
       var anno = MapModule.createAnnotation({
       	latitude : -33.87365,
       	customView : myView1,
       	longitude : 151.20689,
       	title : "Drag Me",
       	subtitle : "Sydney is quite chill",
       	draggable : true
       });
       var anno2 = MapModule.createAnnotation({
       	latitude : -33.86365,
       	image : "applogo.png",
       	longitude : 151.21689,
       	title : "Drag Me 2",
       	subtitle : "This is anno2",
       	leftButton: "face_happy.png",
       	rightView: rightView,
       	draggable : true
       });
       var anno3 = MapModule.createAnnotation({
       	latitude : -33.85365,
       	pincolor : MapModule.ANNOTATION_BLUE,
       	longitude : 151.20689,
       	title : "anno3",
       	subtitle : "This is anno3",
       	rightButton: "face_ok.png",
       	draggable : false
       });
       
       var map = MapModule.createView({
       	enableZoomControls: false,
       	//userLocation: false,
       	mapType: MapModule.NORMAL_TYPE,
       	animate: true,
       	annotations: [anno, anno2, anno3],
       	region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 } //Sydney
       });
       
       map.setLocation({latitude: 0, longitude: 0});
       
       map.addEventListener('pinchangedragstate', function(e) {
       	Ti.API.info(e.title + ": newState=" + e.newState + ", lat=" + e.annotation.latitude + ", lon=" + e.annotation.longitude);
       });
       
       map.addEventListener('click', function(e) {
       	Ti.API.info("Click " + e.title + ": clicksource=" + e.clicksource + ", lat=" + e.annotation.latitude + ", lon=" + e.annotation.longitude);
       });
       
       var b1 = Ti.UI.createButton({
       	title: "Toggle draggable for anno3"
       });
       b1.addEventListener('click', function(){
       	anno3.draggable = !anno3.draggable;
       	Ti.API.info("anno3.draggable = " + anno3.draggable);
       });
       
       var b2 = Ti.UI.createButton({
       	title: "Toggle enableZoomControls for map"
       });
       b2.addEventListener('click', function(){
       	map.enableZoomControls = !map.enableZoomControls;
       	Ti.API.info("map.enableZoomControls = " + map.enableZoomControls);
       });
       
       var b3 = Ti.UI.createButton({
       	title: "Change properties for anno2 (title and left pane should be changed)"
       });
       var i = 0;
       b3.addEventListener('click', function(){
       	Ti.API.info(anno2.leftButton);
       	if (anno2.leftButton != null) {
       		anno2.leftButton = null;
       	} else {
       		anno2.leftButton = "face_happy.png"
       	}
       	Ti.API.info(anno2.leftButton);
       	anno2.leftView = Ti.UI.createLabel({
           	text:"NEW LABEL: " + i
       	});
       	anno2.title = "New anno2: " + i;
       	i++;
       });
       
       var b4 = Ti.UI.createButton({
       	title: "Zoom in/out"
       });
       var zoomLevel = 1;
       b4.addEventListener('click', function(){
       	map.zoom(zoomLevel);
       	Ti.API.info("Zoom in / out with level = " + zoomLevel);
       	zoomLevel = -zoomLevel;
       });
       
       var b5 = Ti.UI.createButton({
       	title: "setLocation"
       });
       var zoomLevel = 1;
       b5.addEventListener('click', function(){
       	map.setLocation({
       		animate: false,
       		latitude: -33.97365,
       		longitude: 151.30689,
       		latitudeDelta: 0.2,
       		longitudeDelta: 0.2
       	});
       });
       
       win.add(b1);
       win.add(b2);
       win.add(b3);
       win.add(b4);
       win.add(b5);
       win.add(map);
       win.open();
       
    Steps for FR: 1. Run the above test case. 2. Click the annotation and info window. Check the log to make sure the "clicksource" is correct. Should be one of pin, title, subtitle, leftPane, rightPane, infoWindow or null. Please test on different devices with different resolutions. 3. Click the button "Change properties for anno2". Deselect and select anno2 to see the change of title and left pane. 4. Click the button "Zoom in/out" to see the map is zoomed in/out. 5. Click the button "setLocation" to see the map location is changed.
  2. Ping Wang 2013-03-29

    PR: https://github.com/appcelerator/titanium_mobile/pull/4061 (3_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/4077) PR: https://github.com/appcelerator/titanium_modules/pull/95
  3. Tommy Leung 2013-04-08

    It still seems to be missing "longitudeDelta" and "latitidueDelta" properties on the "regionchanged" event. Without it, it's impossible to calculate the current lat/lon area (box) the user is currenlty viewing.
  4. Ping Wang 2013-04-10

    Hi Tommy, TIMOB-13516 is created for the missing "longitudeDelta" and "latitidueDelta" properties on the "regionchanged" event.
  5. Dhirendra Jha 2013-09-24

    Environment: Appcelerator Studio: 3.1.3.201309132456 SDK: 3.1.3.GA acs: 1.0.6 alloy: 1.2.2 titanium: 3.1.2 titanium-code-processor: 1.0.3 Xcode: 5 Device: Nexus 7 (4.3) Result - Used the above code, followed the same steps. Now its working fine with all the expected output. Hence closing this issue.
  6. Thierry Ruiz 2014-05-04

    According the doc (http://docs.appcelerator.com/titanium/latest/#!/api/Modules.Map.View-event-longclick) 1. longclick() is only for Android and return Lat & Long 2. longpress() has disappeared but can still be used in a iOS app. However it returns X and Y (pixel) of the map It would be great to uniform this a little bit more. Tested with: Module.Map 2.1.4 (latest) and Titanium 3.2.3GA ------ function map_longClick(e) { if(OS_IOS){ var coordinate = convertPixeltoLatLng(e.x, e.y); } if(OS_ANDROID){ var coordinate = {latitude: e.latitude, longitude: e.longitude}; } var a = MAP.api.createAnnotation({ latitude: coordinate.latitude, longitude: coordinate.longitude, title: "New Place", pincolor: MAP.api.ANNOTATION_GREEN, animate: true, draggable: true }); MAP.mapView.addAnnotation(a); } function convertPixeltoLatLng(x, y) { var region = MAP.mapView.actualRegion || MAP.mapView.region; MAP.log("debug","convertPixeltoLatLng > "+JSON.stringify(region)); var widthInPixels = MAP.mapView.rect.width; var heightInPixels = MAP.mapView.rect.height; var heightDegPerPixel = -region.latitudeDelta / heightInPixels; var widthDegPerPixel = region.longitudeDelta / widthInPixels; coordinates = { latitude: (y - heightInPixels / 2) * heightDegPerPixel + region.latitude, longitude: (x - widthInPixels / 2) * widthDegPerPixel + region.longitude }; return coordinates; },

JSON Source