rhodes 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/LICENSE +19 -674
- data/Manifest.txt +21 -4
- data/README.textile +5 -36
- data/Rakefile +5 -0
- data/lib/build/jake.rb +3 -1
- data/lib/extensions/rexml/rexml/document.rb +2 -0
- data/lib/extensions/rexml/rexml/parsers/baseparser.rb +0 -6
- data/lib/extensions/rhoxml/rexml/child.rb +96 -0
- data/lib/extensions/rhoxml/rexml/document.rb +527 -0
- data/lib/extensions/rhoxml/rexml/element.rb +987 -0
- data/lib/extensions/rhoxml/rexml/encoding.rb +71 -0
- data/lib/extensions/rhoxml/rexml/encodings/US-ASCII.rb +30 -0
- data/lib/extensions/rhoxml/rexml/encodings/UTF-16.rb +35 -0
- data/lib/extensions/rhoxml/rexml/encodings/UTF-8.rb +18 -0
- data/lib/extensions/rhoxml/rexml/namespace.rb +47 -0
- data/lib/extensions/rhoxml/rexml/node.rb +76 -0
- data/lib/extensions/rhoxml/rexml/parent.rb +166 -0
- data/lib/extensions/rhoxml/rexml/parseexception.rb +51 -0
- data/lib/extensions/rhoxml/rexml/parsers/baseparser.rb +531 -0
- data/lib/extensions/rhoxml/rexml/parsers/treeparser.rb +100 -0
- data/lib/extensions/rhoxml/rexml/parsers/xpathparser.rb +698 -0
- data/lib/extensions/rhoxml/rexml/set.rb +1274 -0
- data/lib/extensions/rhoxml/rexml/source.rb +258 -0
- data/lib/extensions/rhoxml/rexml/xmltokens.rb +18 -0
- data/lib/extensions/rhoxml/rexml/xpath.rb +77 -0
- data/lib/extensions/rhoxml/rexml/xpath_parser.rb +806 -0
- data/lib/framework/builtinME.rb +2 -0
- data/lib/framework/dateME.rb +5 -1
- data/lib/framework/rho/render.rb +10 -2
- data/lib/framework/rhom/rhom_object_factory.rb +2 -1
- data/lib/framework/singleton.rb +1 -1
- data/platform/android/Rhodes/jni/src/rhodes.cpp +2 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +23 -18
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +42 -69
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +59 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/Annotation.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +97 -85
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/SmsUriHandler.java +52 -0
- data/platform/android/build/RhodesSRC_build.files +1 -0
- data/platform/android/build/android.rake +38 -14
- data/platform/bb/RubyVM/RubyVM.jdp +1 -0
- data/platform/bb/build/RubyVM_build.files +1 -0
- data/platform/bb/build/bb.rake +44 -2
- data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +1 -1
- data/platform/bb/rhodes/rhodes.jdp +4 -4
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +8 -4
- data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +149 -17
- data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +20 -17
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +54 -28
- data/platform/bb/rhodes/src/rhomobile/mapview/Annotation.java +1 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/GoogleMapField.java +37 -11
- data/platform/bb/rhodes/src/rhomobile/mapview/MapView.java +49 -19
- data/platform/bb/rhodes/src/rhomobile/mapview/MapViewScreen.java +6 -0
- data/platform/iphone/Classes/MapView/GoogleGeocoder.h +6 -7
- data/platform/iphone/Classes/MapView/GoogleGeocoder.m +70 -70
- data/platform/iphone/Classes/MapView/MapAnnotation.h +5 -3
- data/platform/iphone/Classes/MapView/MapAnnotation.m +10 -8
- data/platform/iphone/Classes/MapView/MapViewController.h +13 -10
- data/platform/iphone/Classes/MapView/MapViewController.m +131 -72
- data/platform/iphone/Classes/Rhodes.h +2 -0
- data/platform/iphone/Classes/Rhodes.m +13 -1
- data/platform/iphone/Classes/SimpleMainView.m +0 -1
- data/platform/iphone/Classes/TabbedMainView.m +5 -6
- data/platform/shared/common/RhoTime.h +2 -2
- data/platform/shared/common/RhodesApp.cpp +1 -1
- data/platform/shared/db/DBAdapter.cpp +6 -0
- data/platform/shared/net/CURLNetRequest.cpp +23 -1
- data/platform/shared/ruby/thread_win32.c +9 -1
- data/platform/shared/rubyJVM/src/com/rho/Capabilities.java +6 -0
- data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +1 -1
- data/platform/shared/rubyJVM/src/com/rho/sync/ClientRegister.java +1 -1
- data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubySymbol_Methods.java +6 -1
- data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubyTime_Methods.java +3 -3
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/InputStreamExecutor.java +1 -1
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyArray.java +15 -3
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyString.java +10 -2
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyTime.java +12 -1
- data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubyKernelModule.java +18 -9
- data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubySymbol.java +5 -0
- data/platform/shared/rubyJVM/src/org/json/me/JSONArray.java +2 -1
- data/platform/shared/unzip/unzip.cpp +1 -1
- data/platform/wm/build/wm.rake +27 -6
- data/platform/wm/rhodes/Alert.cpp +335 -5
- data/platform/wm/rhodes/Alert.h +84 -1
- data/platform/wm/rhodes/MainWindow.cpp +28 -6
- data/platform/wm/rhodes/MainWindow.h +7 -2
- data/platform/wm/rhodes/Rhodes.cpp +23 -0
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +2 -1
- data/platform/wm/rhodes/stdafx.h +1 -0
- data/platform/wm/tools/detool/detool.cpp +405 -14
- data/rakefile.rb +5 -0
- data/res/build-tools/detool.exe +0 -0
- data/res/generators/rhogen.rb +2 -0
- data/rhodes.gemspec +1 -1
- data/spec/framework_spec/app/spec/fixtures/object_values.txt +1 -1
- data/spec/framework_spec/app/spec/pagination/fixtures/object_values.txt +1 -1
- data/spec/framework_spec/app/spec/rhom_object_spec.rb +12 -12
- metadata +23 -6
- data/LICENSING_OPTIONS +0 -1
- data/platform/bb/build/rhodesApp.rapc +0 -9
- data/res/generators/templates/source/source_adapter.rb +0 -48
- data/rhobuild.yml +0 -37
@@ -6,6 +6,10 @@ import java.util.Enumeration;
|
|
6
6
|
import java.util.Hashtable;
|
7
7
|
import java.util.Vector;
|
8
8
|
|
9
|
+
import org.json.me.JSONArray;
|
10
|
+
import org.json.me.JSONException;
|
11
|
+
import org.json.me.JSONObject;
|
12
|
+
|
9
13
|
import j2me.lang.MathEx;
|
10
14
|
|
11
15
|
import com.rho.RhoClassFactory;
|
@@ -374,7 +378,7 @@ public class GoogleMapField extends Field implements RhoMapField {
|
|
374
378
|
cmd.mapField.draw(cmd.latitude, cmd.longitude, cmd.zoom, img);
|
375
379
|
}
|
376
380
|
|
377
|
-
private void processCommand(MapGeocodingCommand cmd) throws IOException {
|
381
|
+
private void processCommand(MapGeocodingCommand cmd) throws IOException, JSONException {
|
378
382
|
LOG.TRACE("Processing map geocoding command (thread #" + hashCode() + "): " + cmd.description());
|
379
383
|
|
380
384
|
if (cmd.annotation.street_address == null) {
|
@@ -385,7 +389,7 @@ public class GoogleMapField extends Field implements RhoMapField {
|
|
385
389
|
StringBuffer url = new StringBuffer();
|
386
390
|
url.append("http://maps.google.com/maps/geo?");
|
387
391
|
url.append("q=" + URI.urlEncode(cmd.annotation.street_address));
|
388
|
-
url.append("&output=
|
392
|
+
url.append("&output=json&mobile=true&sensor=false");
|
389
393
|
url.append("&key=" + mapkey);
|
390
394
|
|
391
395
|
String finalUrl = url.toString();
|
@@ -393,6 +397,30 @@ public class GoogleMapField extends Field implements RhoMapField {
|
|
393
397
|
byte[] data = fetchData(finalUrl);
|
394
398
|
String response = new String(data);
|
395
399
|
|
400
|
+
JSONObject resp = new JSONObject(response);
|
401
|
+
JSONObject status = resp.getJSONObject("Status");
|
402
|
+
int statusCode = status.getInt("code");
|
403
|
+
if (statusCode/100 != 2) {
|
404
|
+
LOG.ERROR("Error received from geocoding service: " + statusCode);
|
405
|
+
return;
|
406
|
+
}
|
407
|
+
|
408
|
+
JSONArray placemarks = resp.getJSONArray("Placemark");
|
409
|
+
if (placemarks.length() == 0) {
|
410
|
+
LOG.ERROR("Geocoding request return empty response");
|
411
|
+
return;
|
412
|
+
}
|
413
|
+
JSONObject placemark = placemarks.getJSONObject(0);
|
414
|
+
JSONObject point = placemark.getJSONObject("Point");
|
415
|
+
JSONArray coordinates = point.getJSONArray("coordinates");
|
416
|
+
if (coordinates.length() < 2) {
|
417
|
+
LOG.ERROR("Geocoding response contains less than 2 coordinates");
|
418
|
+
return;
|
419
|
+
}
|
420
|
+
double longitude = coordinates.getDouble(0);
|
421
|
+
double latitude = coordinates.getDouble(1);
|
422
|
+
|
423
|
+
/*
|
396
424
|
// Parse response
|
397
425
|
Vector res = split(response, ",");
|
398
426
|
if (res.size() != 4) {
|
@@ -404,9 +432,10 @@ public class GoogleMapField extends Field implements RhoMapField {
|
|
404
432
|
int accuracy = Integer.parseInt((String)res.elementAt(1));
|
405
433
|
double latitude = Double.parseDouble((String)res.elementAt(2));
|
406
434
|
double longitude = Double.parseDouble((String)res.elementAt(3));
|
435
|
+
*/
|
407
436
|
|
408
437
|
LOG.TRACE("Geocoding request done, pass results back");
|
409
|
-
cmd.mapField.geocodingDone(cmd.annotation,
|
438
|
+
cmd.mapField.geocodingDone(cmd.annotation, latitude, longitude);
|
410
439
|
}
|
411
440
|
|
412
441
|
public void run() {
|
@@ -903,19 +932,16 @@ public class GoogleMapField extends Field implements RhoMapField {
|
|
903
932
|
fetchThreadPool.send(new MapGeocodingCommand(ann, this));
|
904
933
|
}
|
905
934
|
|
906
|
-
private void geocodingDone(Annotation ann,
|
907
|
-
int accuracy, double lat, double lon) {
|
935
|
+
private void geocodingDone(Annotation ann, double lat, double lon) {
|
908
936
|
|
909
|
-
LOG.TRACE("Apply geocoding result: " +
|
910
|
-
"," + lat + "," + lon);
|
911
|
-
if (statusCode/100 != 2) {
|
912
|
-
LOG.ERROR("Error received from geocoding service: " + statusCode);
|
913
|
-
return;
|
914
|
-
}
|
937
|
+
LOG.TRACE("Apply geocoding result: " + lat + "," + lon);
|
915
938
|
ann.coordinates = new Annotation.Coordinates(lat, lon);
|
916
939
|
long nlat = degreesToPixelsY(lat, MAX_ZOOM);
|
917
940
|
long nlon = degreesToPixelsX(lon, MAX_ZOOM);
|
918
941
|
ann.normalized_coordinates = new Annotation.NormalizedCoordinates(nlat, nlon);
|
942
|
+
if (ann.type.equals("center")) {
|
943
|
+
moveTo(lat, lon);
|
944
|
+
}
|
919
945
|
}
|
920
946
|
|
921
947
|
private static int calcZoom(double degrees, int pixels) {
|
@@ -117,28 +117,57 @@ public class MapView extends RubyBasic {
|
|
117
117
|
else if (strKey.equals("shows_user_location"))
|
118
118
|
settings.put(strKey, new Boolean(value.toString().equalsIgnoreCase("true")));
|
119
119
|
else if (strKey.equals("region")) {
|
120
|
-
if (
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
120
|
+
if (value instanceof RubyArray) {
|
121
|
+
RubyArray arr = (RubyArray)value;
|
122
|
+
if (arr.size() == 4) {
|
123
|
+
Hashtable region = new Hashtable();
|
124
|
+
double[] cs = {0.0, 0.0, 0.0, 0.0};
|
125
|
+
for (int k = 0; k != 4; ++k) {
|
126
|
+
String v = arr.get(k).toString();
|
127
|
+
try {
|
128
|
+
cs[k] = Double.parseDouble(v);
|
129
|
+
}
|
130
|
+
catch (NumberFormatException e) {
|
131
|
+
throw new RubyException(RubyRuntime.ArgumentErrorClass,
|
132
|
+
"Wrong region value: " + v + ", should be Float");
|
133
|
+
}
|
134
|
+
}
|
135
|
+
region.put("latitude", new Double(cs[0]));
|
136
|
+
region.put("longitude", new Double(cs[1]));
|
137
|
+
region.put("latDelta", new Double(cs[2]));
|
138
|
+
region.put("lonDelta", new Double(cs[3]));
|
139
|
+
settings.put(strKey, region);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
else if (value instanceof RubyHash) {
|
143
|
+
RubyHash hsh = (RubyHash)value;
|
144
|
+
RubyArray hKeys = hsh.keys();
|
145
|
+
RubyArray hValues = hsh.values();
|
146
|
+
for (int j = 0; j < hKeys.size(); ++j) {
|
147
|
+
RubyValue hKey = hKeys.get(j);
|
148
|
+
RubyValue hValue = hValues.get(j);
|
149
|
+
if (hKey == null || hValue == null)
|
150
|
+
continue;
|
151
|
+
|
152
|
+
String strHKey = hKey.toString();
|
153
|
+
if (strHKey.equals("center")) {
|
154
|
+
Annotation ann = new Annotation();
|
155
|
+
ann.type = "center";
|
156
|
+
ann.street_address = hValue.toString();
|
157
|
+
annotations.addElement(ann);
|
131
158
|
}
|
132
|
-
|
133
|
-
|
134
|
-
|
159
|
+
else if (strHKey.equals("radius")) {
|
160
|
+
String strHValue = hValue.toString();
|
161
|
+
try {
|
162
|
+
double radius = Double.parseDouble(strHValue);
|
163
|
+
settings.put("radius", new Double(radius));
|
164
|
+
}
|
165
|
+
catch (NumberFormatException e) {
|
166
|
+
throw new RubyException(RubyRuntime.ArgumentErrorClass,
|
167
|
+
"Wrong 'radius' parameter: " + strHValue + ", should be Float");
|
168
|
+
}
|
135
169
|
}
|
136
170
|
}
|
137
|
-
region.put("latitude", new Double(cs[0]));
|
138
|
-
region.put("longitude", new Double(cs[1]));
|
139
|
-
region.put("latDelta", new Double(cs[2]));
|
140
|
-
region.put("lonDelta", new Double(cs[3]));
|
141
|
-
settings.put(strKey, region);
|
142
171
|
}
|
143
172
|
}
|
144
173
|
}
|
@@ -147,6 +176,7 @@ public class MapView extends RubyBasic {
|
|
147
176
|
if (annotationsArray != null) {
|
148
177
|
for (int i = 0; i != annotationsArray.size(); ++i) {
|
149
178
|
Annotation annotation = new Annotation();
|
179
|
+
annotation.type = "ann";
|
150
180
|
RubyValue val = annotationsArray.get(i);
|
151
181
|
if (!(val instanceof RubyHash))
|
152
182
|
throw new RubyException(RubyRuntime.ArgumentErrorClass,
|
@@ -129,6 +129,12 @@ public class MapViewScreen extends MainScreen {
|
|
129
129
|
}
|
130
130
|
}
|
131
131
|
|
132
|
+
Double radius = (Double)settings.get("radius");
|
133
|
+
if (radius != null) {
|
134
|
+
int zoom = mapField.calculateZoom(radius.doubleValue(), radius.doubleValue());
|
135
|
+
mapField.setZoom(zoom);
|
136
|
+
}
|
137
|
+
|
132
138
|
// Annotations
|
133
139
|
Enumeration e = annotations.elements();
|
134
140
|
while (e.hasMoreElements()) {
|
@@ -7,14 +7,13 @@
|
|
7
7
|
#define kGeoCodeURL @"http://maps.google.com/maps/geo?q="
|
8
8
|
|
9
9
|
@interface GoogleGeocoder : NSObject {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
NSMutableArray *annotations;
|
11
|
+
MapAnnotation* currentAnnotation;
|
12
|
+
NSString *theElement;
|
13
|
+
NSString *gapikey;
|
14
14
|
@public
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
id actionTarget;
|
16
|
+
SEL onDidFindAddress;
|
18
17
|
}
|
19
18
|
|
20
19
|
//
|
@@ -11,88 +11,88 @@
|
|
11
11
|
@synthesize actionTarget,onDidFindAddress,theElement,annotations,gapikey;
|
12
12
|
|
13
13
|
-(void)doGeocoding:(NSMutableArray*)items {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
14
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
15
|
+
|
16
|
+
NSEnumerator * enumerator = [items objectEnumerator];
|
17
|
+
MapAnnotation* annotation, *element;
|
18
|
+
while(element = [enumerator nextObject]) {
|
19
|
+
annotation = nil;
|
20
|
+
if ( (element.coordinate.latitude==10000) ||
|
21
|
+
(element.coordinate.longitude==10000) ) {
|
22
|
+
NSString* address = [element address];
|
23
|
+
if ( ([address length] > 0) && [self geocode:element]) {
|
24
|
+
annotation = element;
|
25
|
+
}
|
26
|
+
} else {
|
27
|
+
annotation = element;
|
28
|
+
}
|
29
|
+
|
30
|
+
if(annotation && actionTarget && [actionTarget respondsToSelector:onDidFindAddress]) {
|
31
|
+
[actionTarget performSelectorOnMainThread:onDidFindAddress withObject:annotation waitUntilDone:NO];
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
35
|
[pool release];
|
36
36
|
}
|
37
37
|
|
38
38
|
-(void)start {
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
if (annotations) {
|
40
|
+
[NSThread detachNewThreadSelector:@selector(doGeocoding:) toTarget:self withObject:annotations];
|
41
|
+
}
|
42
42
|
}
|
43
43
|
|
44
44
|
-(id)initWithAnnotations:(NSMutableArray*)_annotations apikey:(NSString*)key{
|
45
|
-
|
45
|
+
self = [super init];
|
46
46
|
annotations = _annotations;
|
47
|
-
|
47
|
+
gapikey = [key copy];
|
48
48
|
return self;
|
49
49
|
}
|
50
50
|
|
51
51
|
-(BOOL)geocode:(MapAnnotation *)annotation
|
52
52
|
{
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
53
|
+
BOOL retvar = TRUE;
|
54
|
+
currentAnnotation = annotation;
|
55
|
+
NSMutableString *url = [[NSMutableString alloc] initWithString:kGeoCodeURL];
|
56
|
+
[url appendString:[annotation address]];
|
57
|
+
[url appendFormat:@"&output=xml"];
|
58
|
+
[url replaceOccurrencesOfString:@"ä" withString:@"ae" options:1 range:(NSRange){0,[url length]}];
|
59
|
+
[url replaceOccurrencesOfString:@"ö" withString:@"oe" options:1 range:(NSRange){0,[url length]}];
|
60
|
+
[url replaceOccurrencesOfString:@"ü" withString:@"ue" options:1 range:(NSRange){0,[url length]}];
|
61
|
+
[url replaceOccurrencesOfString:@"ß" withString:@"ss" options:1 range:(NSRange){0,[url length]}];
|
62
|
+
[url replaceOccurrencesOfString:@" " withString:@"+" options:1 range:(NSRange){0,[url length]}];
|
63
|
+
if (gapikey) {
|
64
|
+
[url appendString:@"&key="];
|
65
|
+
[url appendString:gapikey];
|
66
|
+
}
|
67
|
+
NSLog(@"Geocoding url = %@\n", url);
|
68
|
+
NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:url]
|
69
|
+
cachePolicy:NSURLRequestUseProtocolCachePolicy
|
70
|
+
timeoutInterval:60.0];
|
71
|
+
@try {
|
72
|
+
NSHTTPURLResponse *response = NULL;
|
73
|
+
NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
|
74
|
+
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
|
75
|
+
[parser setDelegate:self];
|
76
|
+
[parser parse];
|
77
|
+
[self stringCooridinatesToCLLocation];
|
78
|
+
}
|
79
|
+
@catch (NSException *exception) {
|
80
|
+
NSLog(@"Geocoding failed");
|
81
|
+
retvar = FALSE;
|
82
|
+
}
|
83
|
+
@finally {
|
84
|
+
//NSLog(@"finally");
|
85
|
+
}
|
86
|
+
return retvar;
|
87
87
|
}
|
88
88
|
|
89
89
|
-(CLLocation *)stringCooridinatesToCLLocation{
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
90
|
+
NSArray *array = [[currentAnnotation coordinateString] componentsSeparatedByString:@","];
|
91
|
+
double longitude = [[array objectAtIndex:0] doubleValue];
|
92
|
+
double lattitude = [[array objectAtIndex:1] doubleValue];
|
93
|
+
CLLocation *location = [[[CLLocation alloc] initWithLatitude:lattitude longitude:longitude] autorelease];
|
94
|
+
[currentAnnotation setCoordinate:location.coordinate];
|
95
|
+
return location;
|
96
96
|
}
|
97
97
|
|
98
98
|
#pragma mark -
|
@@ -101,8 +101,8 @@
|
|
101
101
|
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
|
102
102
|
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
|
103
103
|
attributes:(NSDictionary *)attributeDict {
|
104
|
-
|
105
|
-
|
104
|
+
if(theElement) [theElement release];
|
105
|
+
theElement = [[NSString alloc] initWithString:elementName];
|
106
106
|
}
|
107
107
|
|
108
108
|
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
|
@@ -111,10 +111,10 @@
|
|
111
111
|
if ([string length] == 0)
|
112
112
|
return;
|
113
113
|
|
114
|
-
|
114
|
+
if([theElement isEqualToString:@"address"])
|
115
115
|
[currentAnnotation setResolvedAddress:string];
|
116
116
|
|
117
|
-
|
117
|
+
if([theElement isEqualToString:@"coordinates"])
|
118
118
|
[currentAnnotation setCoordinateString:string];
|
119
119
|
}
|
120
120
|
|
@@ -13,11 +13,13 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
@interface MapAnnotation : NSObject<MKAnnotation> {
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
NSString *type;
|
17
|
+
NSString *title, *subtitle, *address, *url;
|
18
|
+
NSString *coordinateString,*resolvedAddress;
|
19
|
+
CLLocationCoordinate2D coordinate;
|
19
20
|
}
|
20
21
|
|
22
|
+
@property (nonatomic,copy) NSString *type;
|
21
23
|
@property (nonatomic,copy) NSString *title;
|
22
24
|
@property (nonatomic,copy) NSString *subtitle;
|
23
25
|
@property (nonatomic,copy) NSString *address;
|
@@ -12,20 +12,22 @@
|
|
12
12
|
|
13
13
|
@implementation MapAnnotation
|
14
14
|
|
15
|
-
@synthesize title, subtitle, address, url, coordinateString, resolvedAddress, coordinate;
|
15
|
+
@synthesize type, title, subtitle, address, url, coordinateString, resolvedAddress, coordinate;
|
16
16
|
|
17
17
|
-(id) init {
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
[super init];
|
19
|
+
type = [[NSString alloc] initWithFormat:@"ann"];
|
20
|
+
title = [[NSString alloc] initWithFormat:@""];
|
21
|
+
subtitle = [[NSString alloc] initWithFormat:@""];
|
21
22
|
address = [[NSString alloc] initWithFormat:@""];
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
coordinateString = [[NSMutableString alloc] initWithFormat:@""];
|
24
|
+
resolvedAddress = [[NSMutableString alloc] initWithFormat:@""];
|
25
|
+
url = [[NSString alloc] initWithFormat:@""];
|
26
|
+
return self;
|
26
27
|
}
|
27
28
|
|
28
29
|
-(void) dealloc {
|
30
|
+
[type release];
|
29
31
|
[title release];
|
30
32
|
[subtitle release];
|
31
33
|
[address release];
|