Toggle navigation
Toggle navigation
This project
Loading...
Sign in
尹诚
/
Mapbox-iOS-SDK
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Thomas Rasch
13 years ago
Commit
9ac509c20ae06eb76c120836f773ddf92f9f688b
1 parent
40f28702
o Synchronize path movement with the map scroll view (closes #7)
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
53 deletions
MapView/Map/RMCircle.m
MapView/Map/RMMapOverlayView.m
MapView/Map/RMPath.h
MapView/Map/RMPath.m
MapView/Map/RMCircle.m
View file @
9ac509c
...
...
@@ -29,7 +29,7 @@
#import "RMProjection.h"
#import "RMMapView.h"
#define kDefaultLineWidth 10
#define kDefaultLineWidth 10
.0
#define kDefaultLineColor [UIColor blackColor]
#define kDefaultFillColor [UIColor blueColor]
...
...
@@ -116,7 +116,7 @@
[
self
.
shapeLayer
setLineWidth
:
lineWidthInPixels
];
}
#pragma mark Accessors
#pragma mark
-
Accessors
-
(
void
)
setLineColor
:
(
UIColor
*
)
newLineColor
{
...
...
MapView/Map/RMMapOverlayView.m
View file @
9ac509c
...
...
@@ -118,6 +118,7 @@
return
[((
RMMarker
*
)
layer
)
annotation
];
CALayer
*
superlayer
=
[
layer
superlayer
];
if
(
superlayer
!=
nil
&&
[
superlayer
respondsToSelector
:
@selector
(
annotation
)])
return
[((
RMMarker
*
)
superlayer
)
annotation
];
else
if
([
superlayer
superlayer
]
!=
nil
&&
[[
superlayer
superlayer
]
respondsToSelector
:
@selector
(
annotation
)])
...
...
MapView/Map/RMPath.h
View file @
9ac509c
...
...
@@ -32,8 +32,6 @@
@class
RMMapView
;
/*! \brief buggy, incomplete, untested; overlays paths/polygons on map
*/
@interface
RMPath
:
RMMapLayer
{
BOOL
isFirstPoint
;
...
...
@@ -48,7 +46,7 @@
BOOL
ignorePathUpdates
;
CGRect
previousBounds
;
/// Width of the line,
units unknown; pixels maybe?
/// Width of the line,
in pixels
float
lineWidth
;
/*! Drawing mode of the path; Choices are
...
...
MapView/Map/RMPath.m
View file @
9ac509c
...
...
@@ -41,7 +41,7 @@
@synthesize
enableShadow
;
@synthesize
pathBoundingBox
;
#define kDefaultLineWidth 2
#define kDefaultLineWidth 2
.0
-
(
id
)
initWithView
:(
RMMapView
*
)
aMapView
{
...
...
@@ -78,9 +78,7 @@
isFirstPoint
=
YES
;
if
([
self
respondsToSelector
:
@selector
(
setContentsScale
:)])
{
[(
id
)
self
setValue
:[[
UIScreen
mainScreen
]
valueForKey
:
@"scale"
]
forKey
:
@"contentsScale"
];
}
return
self
;
}
...
...
@@ -95,10 +93,12 @@
[
super
dealloc
];
}
-
(
id
<
CAAction
>
)
actionForKey
:
(
NSString
*
)
key
{
return
nil
;
}
//- (id <CAAction>)actionForKey:(NSString *)key
//{
// return nil;
//}
#pragma mark -
-
(
void
)
recalculateGeometry
{
...
...
@@ -175,6 +175,50 @@
[
self
setNeedsDisplay
];
}
-
(
void
)
drawInContext
:
(
CGContextRef
)
theContext
{
renderedScale
=
[
mapView
metersPerPixel
];
CGFloat
*
dashLengths
=
_lineDashLengths
;
float
scale
=
1
.
0
f
/
[
mapView
metersPerPixel
];
float
scaledLineWidth
=
lineWidth
;
if
(
!
scaleLineWidth
)
scaledLineWidth
*=
renderedScale
;
// NSLog(@"line width = %f, content scale = %f", scaledLineWidth, renderedScale);
if
(
!
scaleLineDash
&&
_lineDashLengths
)
{
dashLengths
=
_scaledLineDashLengths
;
for
(
size_t
dashIndex
=
0
;
dashIndex
<
_lineDashCount
;
dashIndex
++
)
dashLengths
[
dashIndex
]
=
_lineDashLengths
[
dashIndex
]
*
renderedScale
;
}
CGContextScaleCTM
(
theContext
,
scale
,
scale
);
CGContextBeginPath
(
theContext
);
CGContextAddPath
(
theContext
,
path
);
CGContextSetLineWidth
(
theContext
,
scaledLineWidth
);
CGContextSetLineCap
(
theContext
,
lineCap
);
CGContextSetLineJoin
(
theContext
,
lineJoin
);
CGContextSetStrokeColorWithColor
(
theContext
,
[
lineColor
CGColor
]);
CGContextSetFillColorWithColor
(
theContext
,
[
fillColor
CGColor
]);
if
(
_lineDashLengths
)
CGContextSetLineDash
(
theContext
,
lineDashPhase
,
dashLengths
,
_lineDashCount
);
if
(
self
.
enableShadow
)
CGContextSetShadow
(
theContext
,
self
.
shadowOffset
,
self
.
shadowBlur
);
// according to Apple's documentation, DrawPath closes the path if it's a filled style, so a call to ClosePath isn't necessary
CGContextDrawPath
(
theContext
,
drawingMode
);
}
#pragma mark -
-
(
void
)
addPointToProjectedPoint
:
(
RMProjectedPoint
)
point
withDrawing
:
(
BOOL
)
isDrawing
{
// RMLog(@"addLineToXY %f %f", point.x, point.y);
...
...
@@ -243,50 +287,11 @@
ignorePathUpdates
=
YES
;
block
(
self
);
ignorePathUpdates
=
NO
;
[
self
recalculateGeometry
];
}
-
(
void
)
drawInContext
:
(
CGContextRef
)
theContext
{
renderedScale
=
[
mapView
metersPerPixel
];
CGFloat
*
dashLengths
=
_lineDashLengths
;
float
scale
=
1
.
0
f
/
[
mapView
metersPerPixel
];
float
scaledLineWidth
=
lineWidth
;
if
(
!
scaleLineWidth
)
scaledLineWidth
*=
renderedScale
;
// NSLog(@"line width = %f, content scale = %f", scaledLineWidth, renderedScale);
if
(
!
scaleLineDash
&&
_lineDashLengths
)
{
dashLengths
=
_scaledLineDashLengths
;
for
(
size_t
dashIndex
=
0
;
dashIndex
<
_lineDashCount
;
dashIndex
++
)
dashLengths
[
dashIndex
]
=
_lineDashLengths
[
dashIndex
]
*
renderedScale
;
}
CGContextScaleCTM
(
theContext
,
scale
,
scale
);
CGContextBeginPath
(
theContext
);
CGContextAddPath
(
theContext
,
path
);
CGContextSetLineWidth
(
theContext
,
scaledLineWidth
);
CGContextSetLineCap
(
theContext
,
lineCap
);
CGContextSetLineJoin
(
theContext
,
lineJoin
);
CGContextSetStrokeColorWithColor
(
theContext
,
[
lineColor
CGColor
]);
CGContextSetFillColorWithColor
(
theContext
,
[
fillColor
CGColor
]);
if
(
_lineDashLengths
)
CGContextSetLineDash
(
theContext
,
lineDashPhase
,
dashLengths
,
_lineDashCount
);
if
(
self
.
enableShadow
)
CGContextSetShadow
(
theContext
,
self
.
shadowOffset
,
self
.
shadowBlur
);
// according to Apple's documentation, DrawPath closes the path if it's a filled style, so a call to ClosePath isn't necessary
CGContextDrawPath
(
theContext
,
drawingMode
);
}
#pragma mark - Accessors
-
(
void
)
closePath
{
...
...
Please
register
or
login
to post a comment