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
1212802946a61829c6cf75869f6d7c154ccc3d2b
1 parent
8ebb9b52
master
...
1.6.6
1.6.5-sputnik
1.6.4-sputnik
1.6.3-sputnik
1.6.2-sputnik
1.6.1
1.6.1-sputnik
1.6.0
1.6.0-sputnik
1.5.1
1.5.0
1.4.1
1.4.0
1.3.0
1.2.0
1.2.0-patched
1.1.0
1.0.3
1.0.2
1.0.1
1.0.0
0.5.2
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0
devStable
o Synchronize marker movement with the map scroll view (addresses #7)
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
18 deletions
MapView/Map/RMMapLayer.m
MapView/Map/RMMapView.m
MapView/Map/RMQuadTree.h
MapView/Map/RMQuadTree.m
MapView/Map/RMMapLayer.m
View file @
1212802
...
...
@@ -65,12 +65,12 @@
}
/// return nil for certain animation keys to block core animation
-
(
id
<
CAAction
>
)
actionForKey
:
(
NSString
*
)
key
{
if
([
key
isEqualToString
:
@"position"
]
||
[
key
isEqualToString
:
@"bounds"
])
return
nil
;
else
return
[
super
actionForKey
:
key
];
}
//- (id <CAAction>)actionForKey:(NSString *)key
//{
// if ([key isEqualToString:@"position"] || [key isEqualToString:@"bounds"])
// return nil;
// else
// return [super actionForKey:key];
//}
@end
...
...
MapView/Map/RMMapView.m
View file @
1212802
...
...
@@ -66,7 +66,7 @@
-
(
void
)
createMapView
;
-
(
void
)
correctPositionOfAllAnnotations
;
-
(
void
)
correctPositionOfAllAnnotationsIncludingInvisibles
:(
BOOL
)
correctAllLayers
;
-
(
void
)
correctPositionOfAllAnnotationsIncludingInvisibles
:(
BOOL
)
correctAllLayers
wasZoom
:(
BOOL
)
wasZoom
;
@end
...
...
@@ -100,6 +100,7 @@
float
_lastZoom
;
CGPoint
_lastContentOffset
,
_accumulatedDelta
;
BOOL
_mapScrollViewIsZooming
;
}
@synthesize
decelerationMode
;
...
...
@@ -949,6 +950,8 @@
[
mapScrollView
removeObserver
:
self
forKeyPath
:
@"contentOffset"
];
[
mapScrollView
removeFromSuperview
];
[
mapScrollView
release
];
mapScrollView
=
nil
;
_mapScrollViewIsZooming
=
NO
;
int
tileSideLength
=
[[
self
tileSource
]
tileSideLength
];
CGSize
contentSize
=
CGSizeMake
(
tileSideLength
,
tileSideLength
);
// zoom level 1
...
...
@@ -1028,10 +1031,17 @@
-
(
void
)
scrollViewWillBeginZooming
:
(
UIScrollView
*
)
scrollView
withView
:
(
UIView
*
)
view
{
_mapScrollViewIsZooming
=
YES
;
if
(
_delegateHasBeforeMapZoom
)
[
delegate
beforeMapZoom
:
self
];
}
-
(
void
)
scrollViewDidEndZooming
:
(
UIScrollView
*
)
scrollView
withView
:
(
UIView
*
)
view
atScale
:
(
float
)
scale
{
_mapScrollViewIsZooming
=
NO
;
}
-
(
void
)
scrollViewDidZoom
:
(
UIScrollView
*
)
scrollView
{
[
self
correctPositionOfAllAnnotations
];
...
...
@@ -1189,12 +1199,15 @@
}
else
{
[
self
correctPositionOfAllAnnotations
];
if
(
_mapScrollViewIsZooming
)
[
self
correctPositionOfAllAnnotationsIncludingInvisibles
:
NO
wasZoom
:
YES
];
else
[
self
correctPositionOfAllAnnotations
];
}
}
else
{
[
self
correctPositionOfAllAnnotationsIncludingInvisibles
:
NO
];
[
self
correctPositionOfAllAnnotationsIncludingInvisibles
:
NO
wasZoom
:
YES
];
_lastZoom
=
zoom
;
}
...
...
@@ -1513,11 +1526,21 @@
// RMLog(@"Change annotation at {%f,%f} in mapView {%f,%f}", annotation.position.x, annotation.position.y, mapScrollView.contentSize.width, mapScrollView.contentSize.height);
}
-
(
void
)
correctPositionOfAllAnnotationsIncludingInvisibles
:
(
BOOL
)
correctAllAnnotations
-
(
void
)
correctPositionOfAllAnnotationsIncludingInvisibles
:
(
BOOL
)
correctAllAnnotations
wasZoom
:
(
BOOL
)
wasZoom
{
// Prevent blurry movements
[
CATransaction
begin
];
[
CATransaction
setAnimationDuration
:
0
];
// Synchronize marker movement with the map scroll view
if
(
wasZoom
&&
!
mapScrollView
.
isZooming
)
{
[
CATransaction
setAnimationTimingFunction
:[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
]];
[
CATransaction
setAnimationDuration
:
0
.
30
];
}
else
{
[
CATransaction
setAnimationDuration
:
0
.
0
];
}
_accumulatedDelta
.
x
=
0
.
0
;
_accumulatedDelta
.
y
=
0
.
0
;
...
...
@@ -1549,8 +1572,6 @@
for
(
RMAnnotation
*
annotation
in
annotationsToCorrect
)
{
[
self
correctScreenPosition
:
annotation
];
if
(
annotation
.
layer
==
nil
&&
_delegateHasLayerForAnnotation
)
annotation
.
layer
=
[
delegate
mapView
:
self
layerForAnnotation
:
annotation
];
if
(
annotation
.
layer
==
nil
)
...
...
@@ -1563,6 +1584,8 @@
[
visibleAnnotations
addObject
:
annotation
];
}
[
self
correctScreenPosition
:
annotation
];
[
previousVisibleAnnotations
removeObject
:
annotation
];
}
...
...
@@ -1643,7 +1666,7 @@
-
(
void
)
correctPositionOfAllAnnotations
{
[
self
correctPositionOfAllAnnotationsIncludingInvisibles
:
YES
];
[
self
correctPositionOfAllAnnotationsIncludingInvisibles
:
YES
wasZoom
:
NO
];
}
-
(
NSArray
*
)
annotations
...
...
@@ -1691,7 +1714,7 @@
}
}
[
self
correctPositionOfAllAnnotationsIncludingInvisibles
:
YES
];
[
self
correctPositionOfAllAnnotationsIncludingInvisibles
:
YES
wasZoom
:
NO
];
}
-
(
void
)
removeAnnotation
:
(
RMAnnotation
*
)
annotation
...
...
MapView/Map/RMQuadTree.h
View file @
1212802
...
...
@@ -45,6 +45,8 @@ typedef enum {
@property
(
nonatomic
,
readonly
)
RMQuadTreeNode
*
southWest
;
@property
(
nonatomic
,
readonly
)
RMQuadTreeNode
*
southEast
;
@property
(
nonatomic
,
readonly
)
RMAnnotation
*
cachedClusterAnnotation
;
// Operations on this node and all subnodes
@property
(
nonatomic
,
readonly
)
NSArray
*
enclosedAnnotations
;
@property
(
nonatomic
,
readonly
)
NSUInteger
countEnclosedAnnotations
;
...
...
MapView/Map/RMQuadTree.m
View file @
1212802
...
...
@@ -34,7 +34,7 @@
@synthesize
nodeType
;
@synthesize
boundingBox
,
northWestBoundingBox
,
northEastBoundingBox
,
southWestBoundingBox
,
southEastBoundingBox
;
@synthesize
parentNode
,
northWest
,
northEast
,
southWest
,
southEast
;
@synthesize
parentNode
,
northWest
,
northEast
,
southWest
,
southEast
,
cachedClusterAnnotation
;
-
(
id
)
initWithMapView
:(
RMMapView
*
)
aMapView
forParent
:(
RMQuadTreeNode
*
)
aParentNode
inBoundingBox
:(
RMProjectedRect
)
aBoundingBox
{
...
...
@@ -263,6 +263,11 @@
return
unclusteredAnnotations
;
}
-
(
RMAnnotation
*
)
cachedClusterAnnotation
{
return
cachedClusterAnnotation
;
}
-
(
void
)
addAnnotationsInBoundingBox
:
(
RMProjectedRect
)
aBoundingBox
toMutableArray
:
(
NSMutableArray
*
)
someArray
createClusterAnnotations
:
(
BOOL
)
createClusterAnnotations
withClusterSize
:
(
RMProjectedSize
)
clusterSize
findGravityCenter
:
(
BOOL
)
findGravityCenter
{
if
(
createClusterAnnotations
)
...
...
@@ -316,7 +321,11 @@
clusterMarkerPosition
=
RMProjectedPointMake
(
boundingBox
.
origin
.
x
+
halfWidth
,
boundingBox
.
origin
.
y
+
(
boundingBox
.
size
.
height
/
2
.
0
));
}
cachedClusterAnnotation
=
[[
RMAnnotation
alloc
]
initWithMapView
:
mapView
coordinate
:[[
mapView
projection
]
projectedPointToCoordinate
:
clusterMarkerPosition
]
andTitle
:[
NSString
stringWithFormat
:
@"%d"
,
enclosedAnnotationsCount
]];
CLLocationCoordinate2D
clusterMarkerCoordinate
=
[[
mapView
projection
]
projectedPointToCoordinate
:
clusterMarkerPosition
];
cachedClusterAnnotation
=
[[
RMAnnotation
alloc
]
initWithMapView
:
mapView
coordinate
:
clusterMarkerCoordinate
andTitle
:[
NSString
stringWithFormat
:
@"%d"
,
enclosedAnnotationsCount
]];
cachedClusterAnnotation
.
annotationType
=
kRMClusterAnnotationTypeName
;
cachedClusterAnnotation
.
userInfo
=
self
;
}
...
...
Please
register
or
login
to post a comment