Skip to content

Commit

Permalink
Merge pull request #1754 from cb1kenobi/timob-5698
Browse files Browse the repository at this point in the history
[TIMOB-5698] Ti.Map implementation
  • Loading branch information
nebrius committed Mar 21, 2012
2 parents 5bcb199 + 07ca402 commit 580bd71
Show file tree
Hide file tree
Showing 36 changed files with 614 additions and 192 deletions.
1 change: 1 addition & 0 deletions apidoc/Titanium/Database/DB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ summary: The `Database` instance returned by <Titanium.Database.open> or <Titani
extends: Titanium.Proxy
since: "0.1"
createable: false
platforms: [android, iphone, ipad]
methods:
- name: close
summary: |
Expand Down
1 change: 1 addition & 0 deletions apidoc/Titanium/Database/Database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ summary: |
in-application SQLite database.
extends: Titanium.Module
since: "0.1"
platforms: [android, iphone, ipad]
methods:
- name: install
summary: Installs an SQLite database to device's internal storage.
Expand Down
1 change: 1 addition & 0 deletions apidoc/Titanium/Database/ResultSet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ summary: The ResultSet instance returned by <Titanium.Database.DB.execute>.
extends: Titanium.Proxy
since: "0.1"
createable: false
platforms: [android, iphone, ipad]
methods:
- name: close
summary: |
Expand Down
4 changes: 3 additions & 1 deletion apidoc/Titanium/Map/Annotation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ properties:
On iOS, you can specify a system button icon using one of the
[SystemButton](Titanium.UI.iPhone.SystemButton) constants:
myAnnotation.leftButton = Titanium.UI.iPhone.systemButton.INFO_LIGHT;
myAnnotation.leftButton = Titanium.UI.iPhone.SystemButton.INFO_LIGHT;
Mutually exclusive with `leftView`.
type: [Number,String]
Expand All @@ -85,6 +85,7 @@ properties:
description: |
Mutually exclusive with `leftButton`.
type: Titanium.UI.View
platforms: [android, iphone, ipad]

- name: pinImage
summary: Use <Titanium.Map.Annotation.image> property instead.
Expand Down Expand Up @@ -117,6 +118,7 @@ properties:
description: |
Mutually exclusive with `rightButton`.
type: Titanium.UI.View
platforms: [android, iphone, ipad]

- name: subtitle
summary: Secondary title of the annotation view.
Expand Down
35 changes: 26 additions & 9 deletions apidoc/Titanium/Map/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ description: |
In addition to annotations, iOS supports adding routes to a map view, using
[addRoute](Titanium.Map.View.addRoute).
#### Mobile Web Platform Notes
For Mobile Web, the default map provider is Google. Google Maps does not require you to obtain an API key,
however it is encouraged that you use an API key so that you can monitor your Maps API usage. You can sign
up for the Maps API key on the Google Code web site:
* <a href="https://developers.google.com/maps/signup">developers.google.com/maps/signup</a>
If you get a Maps API key, edit your `tiapp.xml` file and add your new key as the
value for the `<mobileweb><map><apikey>` tag.
<mobileweb>
<map>
<apikey>[key goes here]</apikey>
</map>
</mobileweb>
extends: Titanium.UI.View
excludes: {
events: [ 'singletap', 'doubletap', 'dblclick', 'longclick', 'longpress', 'pinch',
Expand Down Expand Up @@ -195,7 +212,7 @@ events:
- name: index
summary: the annotation index.
type: Number
platforms: [iphone, ipad]
platforms: [iphone, ipad, mobileweb]

- name: title
summary: Title of the annotation.
Expand All @@ -204,12 +221,12 @@ events:
- name: subtitle
summary: Subtitle of the annotation.
type: String
platforms: [android]
platforms: [android, mobileweb]

- name: map
summary: The map view instance.
type: Titanium.Map.View
platforms: [iphone, ipad]
platforms: [iphone, ipad, mobileweb]

- name: clicksource
summary: Source of the click event, such as `pin`, or `leftButton`.
Expand All @@ -222,24 +239,24 @@ events:
- name: latitude
summary: Latitude of the clicked annotation.
type: Number
platforms: [android]
platforms: [android, mobileweb]

- name: longitude
summary: Longitude of the clicked annotation.
type: Number
platforms: [android]
platforms: [android, mobileweb]

- name: complete
summary: Fired when the map completes loading.
platforms: [iphone, ipad]
platforms: [iphone, ipad, mobileweb]

- name: error
summary: Fired when the map receives a mapping error.
platforms: [iphone, ipad]

- name: loading
summary: Fired when the map begins loading.
platforms: [iphone, ipad]
platforms: [iphone, ipad, mobileweb]

- name: regionChanged
summary: Fired when the mapping region changes.
Expand Down Expand Up @@ -304,14 +321,14 @@ properties:
summary: The amount of north-to-south distance displayed on the map, measured in decimal degrees.
type: Number
permission: read-only
platforms: [iphone, ipad]
platforms: [iphone, ipad, mobileweb]
since: "1.9.0"

- name: longitudeDelta
summary: The amount of east-to-west distance displayed on the map, measured in decimal degrees.
type: Number
permission: read-only
platforms: [iphone, ipad]
platforms: [iphone, ipad, mobileweb]
since: "1.9.0"

---
Expand Down
4 changes: 3 additions & 1 deletion apidoc/Titanium/Platform/Platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ methods:

- name: is24HourTimeFormat
summary: Returns whether the system settings are configured to show times in 24-hour format.
description: |
On Mobile Web, this function always returns false.
returns:
type: Boolean
platforms: [android, iphone, ipad]
platforms: [android, iphone, ipad, mobileweb]

properties:
- name: BATTERY_STATE_CHARGING
Expand Down
1 change: 1 addition & 0 deletions apidoc/Titanium/UI/Clipboard/Clipboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Titanium.UI.Clipboard
summary: A module used for accessing clipboard data.
extends: Titanium.Module
since: "1.5"
platforms: [android, iphone, ipad]
methods:
- name: clearData
summary: Clear data of the given mime-type from the clipboard. If no mime-type is given, clear all data from the clipboard.
Expand Down
12 changes: 11 additions & 1 deletion mobileweb/splash/splash.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
left: 50%;
margin-left: -85px;
position: absolute;
top: 15%;
top: 22%;
width: 170px;
}

Expand All @@ -39,6 +39,16 @@
width: 200px;
}

@media all and (max-height: 320px) {
#splash:before {
top: 15%;
}

#splash:after {
bottom: 12%;
}
}

@media all and (min-height: 699px) {
#splash:before {
top: 25%;
Expand Down
8 changes: 2 additions & 6 deletions mobileweb/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@
<link rel="apple-touch-startup-image" href="Default-Portrait.jpg" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)">
<link rel="apple-touch-startup-image" href="Default.jpg" media="screen and (max-device-width: 320px)">

<style>
${ti_css}
</style>
<style>${ti_css}</style>
</head>
<body>
<div id="splash">${splash_screen}</div>
<script>
${ti_js}
</script>
<script>${ti_js}</script>
</body>
</html>
37 changes: 36 additions & 1 deletion mobileweb/themes/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -465,4 +465,39 @@ textarea {
user-select: none;
white-space: nowrap;
width: 100%;
}
}

.TiMapAnnotation {
margin-right: 10px;
}

.TiMapAnnotationLeftButton {
float: left;
margin: 0 8px 8px 0;
}

.TiMapAnnotationRightButton {
float: right;
margin: 0 0 8px 8px;
}

.TiMapAnnotationLeftButton:active,
.TiMapAnnotationRightButton:active {
opacity: 0.7;
}

.TiMapAnnotationContent {
overflow: hidden;
}

.TiMapAnnotation h1 {
font-size: 14px;
font-weight: bold;
margin-top: 0;
}

.TiMapAnnotation p {
font-size: 12px;
margin: 5px 0;
}

Binary file added mobileweb/themes/titanium/Map/location.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobileweb/themes/titanium/Map/marker_green.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobileweb/themes/titanium/Map/marker_purple.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobileweb/themes/titanium/Map/marker_red.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 9 additions & 7 deletions mobileweb/titanium/Ti.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,15 @@ define(
makeLabel("Error messages will only be displayed during development. When your app is packaged for final distribution, no error screen will appear. Test your code!", "28%", "#000", "10pt");

win.addEventListener("postlayout", function() {
win.animate({
duration: 500,
top: 0
}, function() {
win.top = 0;
win.height = "100%";
});
setTimeout(function() {
win.animate({
duration: 500,
top: 0
}, function() {
win.top = 0;
win.height = "100%";
});
}, 1);
});

win.open();
Expand Down
2 changes: 1 addition & 1 deletion mobileweb/titanium/Ti/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define(["Ti/_/Evented", "Ti/_/lang"], function(Evented, lang) {
require.each(["debug", "error", "info", "log", "warn"], function(fn) {
api[fn] = function() {
console[fn]("[" + fn.toUpperCase() + "] " + lang.toArray(arguments).map(function(a) {
return require.is(a, "Object") ? a.toString ? a.toString() : JSON.stringify(a) : a === null ? "null" : a === undefined ? "undefined" : a;
return require.is(a, "Object") ? a.hasOwnProperty("toString") ? a.toString() : JSON.stringify(a) : a === null ? "null" : a === undefined ? "undefined" : a;
}).join(' '));
};
});
Expand Down
11 changes: 4 additions & 7 deletions mobileweb/titanium/Ti/Codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/_/Evented"], function(declare, lang, Ev

decodeString: function(args) {
(!args || !args.source) && paramError("source");
var Buffer = require("Ti/Buffer"),
b = args.source.buffer || "",
var b = args.source.buffer || "",
p = args.position | 0,
l = args.length;
return b.substring(p, l && p + l);
Expand All @@ -31,17 +30,15 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/_/Evented"], function(declare, lang, Ev
(!args || !args.source) && paramError("source");
args.dest || paramError("dest");
args.type || paramError("type");
var Buffer = require("Ti/Buffer");
return dest.append(new Buffer({ buffer: ""+parse(args.type, args.source.buffer) }));
return dest.append(new (require("Ti/Buffer"))({ buffer: ""+parse(args.type, args.source.buffer) }));
},

encodeString: function(args) {
(!args || !args.source) && paramError("source");
args.dest || paramError("dest");
var Buffer = require("Ti/Buffer"),
b = args.source.buffer || "",
var b = args.source.buffer || "",
p = args.destPosition | 0;
b = new Buffer({ buffer: b.substring(args.sourcePosition | 0, args.sourceLength || b.length) });
b = new (require("Ti/Buffer"))({ buffer: b.substring(args.sourcePosition | 0, args.sourceLength || b.length) });
return p ? dest.insert(b, p) : dest.append(b);
},

Expand Down
3 changes: 1 addition & 2 deletions mobileweb/titanium/Ti/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ define(["Ti/_/Evented", "Ti/_/lang"], function(Evented, lang) {
},

createLoginButton: function(parameters) {
var LoginButton = require("Ti/Facebook/LoginButton");
return new LoginButton(parameters);
return new (require("Ti/Facebook/LoginButton"))(parameters);
},

dialog: function(action, params, callback) {
Expand Down
2 changes: 1 addition & 1 deletion mobileweb/titanium/Ti/Facebook/LoginButton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(["Ti/_/declare", "Ti/_/Evented", "Ti/UI/Button", "Ti/Facebook", "Ti/_/lang"], function(declare, Evented, Button, Facebook, lang) {

var imagePrefix = "themes/titanium/Facebook/",
var imagePrefix = "themes/" + require.config.ti.theme + "/Facebook/",
buttonImages = [
"login.png", // Login normal
"logout.png", // Logout normal
Expand Down
8 changes: 4 additions & 4 deletions mobileweb/titanium/Ti/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ define(["Ti/_/Evented", "Ti/_/lang"], function(Evented, lang) {
return lang.setObject("Ti.Map", Evented, {

constants: {
// these constants MUST match the correct order of the markers in Ti.Map.View
ANNOTATION_GREEN: 1,
ANNOTATION_PURPLE: 2,
ANNOTATION_RED: 0,

HYBRID_TYPE: 2,
SATELLITE_TYPE: 1,
STANDARD_TYPE: 0,
TERRAIN_TYPE: 3
},

createAnnotation: function(args) {
var m = require("Ti/Map/Annotation");
return new m(args);
return new (require("Ti/Map/Annotation"))(args);
},

createView: function(args) {
var m = require("Ti/Map/View");
return new m(args);
return new (require("Ti/Map/View"))(args);
}

});
Expand Down

0 comments on commit 580bd71

Please sign in to comment.