|
Loading...
|
route-me-map@googlegroups.com
[Prev] Thread [Next] | [Prev] Date [Next]
[route-me] Re: MBtiles + User Location gisman Sun Apr 08 06:00:33 2012
Hi
Managed to spend some time on this just now
Added that line of code above my marker and it now appears!
thanks so much for your help
I just which the map would move to my location, but think I will put
it on my ipad and see what happens
thanks
tim
ps hope this code helps someone else struggling too
On Apr 5, 4:15 pm, shenstech <[EMAIL PROTECTED]> wrote:
> There is actually a markerManager built into the mapview, and any work
> done with markers needs to be pointed into this markerManager. So, in
> the case of your code above, before you add any markers to the marker
> manager, do something like
>
> markerManager = [mapView markerManager];
>
> If that doesn't work just deal with the mapView's markerManager
> directly at first
>
> [mapView.markerManager addMarker:foo atLatLong:bar];
>
> Also, the simulator does usually get a decent location for me. What
> kind of sources it's using, IP number, OS X specific location
> services, I'm not sure.
>
> On Apr 5, 10:59 am, gisman <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > Hi shentech and others,
>
> > Still no luck but i think I have progressed quite far.
>
> > My header file
>
> > #import <UIKit/UIKit.h>
>
> > #import "RMMapView.h"
> > #import "RMMarker.h"
> > #import "RMMapViewDelegate.h"
> > #import "RMMarkerManager.h"
> > #import "CoreLocation/CoreLocation.h"
>
> > @interface MBTiles_ExampleViewController : UIViewController
> > {
> > RMMapView *mapView;
>
> > }
>
> > @property (nonatomic, retain) IBOutlet RMMapView *mapView;
> > @property (nonatomic, retain) CLLocationManager *locationManager;
> > @property (nonatomic, retain) CLLocation *currentLocation;
> > @property (nonatomic, retain) RMMarkerManager *markerManager;
> > @property (nonatomic, retain) RMMarker *locationMarker;
>
> > @end
>
> > My implementation file
>
> > #define kStartingLat 30.0f
> > #define kStartingLon -10.0f
> > #define kStartingZoom 1.5f
>
> > #import "MBTiles_ExampleViewController.h"
>
> > #import "RMMBTilesTileSource.h"
> > #import "RMMapContents.h"
> > #import "RMMarker.h"
>
> > #import "RMMarkerManager.h"
> > #import "CoreLocation/CoreLocation.h"
>
> > @implementation MBTiles_ExampleViewController
>
> > @synthesize mapView;
> > @synthesize currentLocation;
> > @synthesize locationManager;
> > @synthesize markerManager;
> > @synthesize locationMarker;
>
> > - (void)viewDidLoad
> > {
> > CLLocationCoordinate2D startingPoint;
>
> > startingPoint.latitude = kStartingLat;
> > startingPoint.longitude = kStartingLon;
>
> > NSURL *tilesURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]
> > pathForResource:@"control-room-0.2.0" ofType:@"mbtiles"]];
>
> > RMMBTilesTileSource *source = [[[RMMBTilesTileSource alloc]
> > initWithTileSetURL:tilesURL] autorelease];
>
> > [[[RMMapContents alloc] initWithView:self.mapView
> > tilesource:source
> > centerLatLon:startingPoint
> > zoomLevel:kStartingZoom
> > maxZoomLevel:[source maxZoom]
> > minZoomLevel:[source minZoom]
> > backgroundImage:nil] autorelease];
>
> > mapView.enableRotate = NO;
> > mapView.deceleration = NO;
>
> > mapView.backgroundColor = [UIColor blackColor];
>
> > mapView.contents.zoom = kStartingZoom;
>
> > if (nil == locationManager)
> > locationManager = [[CLLocationManager alloc] init];
> > locationManager.delegate = self;
>
> > locationManager.desiredAccuracy = kCLLocationAccuracyBest;
>
> > [locationManager startUpdatingLocation];
>
> > UIImage *iconImage = [UIImage imageNamed:@"marker.png"];
>
> > locationMarker = [[RMMarker alloc] initWithUIImage: iconImage];
>
> > [markerManager addMarker: locationMarker AtLatLong:
> > startingPoint];
>
> > }
>
> > - (void)locationManager:(CLLocationManager *)manager
> > didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation
> > *)oldLocation
> > {
> > [mapView moveToLatLong:newLocation.coordinate];
>
> > RMLatLong newCoords = {newLocation.coordinate.latitude,
> > newLocation.coordinate.longitude};
>
> > if (nil != markerManager)
> > [markerManager moveMarker:locationMarker AtLatLon: newCoords];
>
> > }
>
> > - (void)dealloc
> > {
> > [mapView release];
>
> > [super dealloc];
>
> > }
>
> > @end
>
> > I have a marker.png in my resources folder, however it is not shown at
> > the starting point or when the app moves to the currentLocation.
>
> > So my questions
>
> > 1) Why is my starting marker not showing?
>
> > 2) I am using xcode on SnowLeopard, so can the simulator actually find
> > my location? As the map does not move.
>
> > Any help would be great as I have tried so many code snippets and
> > tutorials but none have ended up working.
>
> > thanks
>
> > Tim
>
> > On Apr 4, 6:18 pm, shenstech <[EMAIL PROTECTED]> wrote:
>
> > > Here is some of my marker code, I think you'll find what you're
> > > looking for here:
>
> > > RMMarker *curMarker;
> > > CLLocationCoordinate2D curLocation;
>
> > > curMarker = [[RMMarker alloc] initWithUIImage:
> > > coloredStop];
>
> > > NSNumber *numLon = [NSNumber numberWithFloat: //Insert
> > > your Lon
> > > here];
> > > NSNumber *numLat = [NSNumber numberWithFloat: //Insert
> > > your Lat
> > > here];
>
> > > curLocation.latitude = [numLat floatValue];
> > > curLocation.longitude = [numLon floatValue];
>
> > > [yourMarkerManager addMarker:curMarker
> > >
> > > AtLatLong:curLocation];
>
> > > On Apr 4, 6:27 am, gisman <[EMAIL PROTECTED]> wrote:
>
> > > > Hi All
>
> > > > I have just started with xcode and route-me so sorry for such a basic
> > > > question. I have got the MBtiles example working with my own data and
> > > > its fantastic.
>
> > > > I now want to add a button that locates the 'user' with a little
> > > > marker, much like the blue dot.
>
> > > > I have done a few tutorials about the Core Location framework and have
> > > > managed to create some text fields with the lat/long values.
>
> > > > However I am struggling to do that with route-me, and a button plus a
> > > > marker. I see there is a RMMarker but how do I pass the lat/long to
> > > > it?
>
> > > > There were some old posts about a user location but no one posted a
> > > > solution, so hoping someone could help
>
> > > > thanks
--
You received this message because you are subscribed to the Google Groups
"route-me" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/route-me-map?hl=en.
- [route-me] MBtiles + User Location gisman 2012/04/04
- [route-me] Re: MBtiles + User Location shenstech 2012/04/04
- [route-me] Re: MBtiles + User Location gisman 2012/04/05
- [route-me] Re: MBtiles + User Location shenstech 2012/04/05
- [route-me] Re: MBtiles + User Location gisman 2012/04/08 <=