Commit Graph

185 Commits

Author SHA1 Message Date
Mark Allen
b915f05a06 [ios] Support for a customizable zoom gesture centering strategy. (#5302)
* [ios] Support for a customizable zoom gesture centering strategy.

We introduce a new MGLZoomGestureCentering enum and corresponding zoomGestureCentering property on MGLMapView.

Currently, Mapbox automatically adjusts the center of the map relative to the user's gesture location, but for some applications (e.g Uber, Lyft) it is preferable to keep the map center "locked" in response to zoom gestures.

Exisiting code will retain its current behavior without modification and will implicitly use the default value of MGLZoomGestureCenteringFollowsTouch. New code can specify MGLZoomGestureCenteringLockedInPlace to get the new "locked" behavior.

* [ios] Added -anchorPointForGesture: to MGLMapView
2016-06-09 17:05:15 -07:00
Minh Nguyễn
e503f9279f Fix crash in userLocationVerticalAlignment, analyzer warning (#5278)
* [ios] Fixed crash in userLocationVerticalAlignment

Avoid creating an array with nil.

Fixes #5274.

* [ios] Fixed analyzer warning

Fixed a write-without-read analyzer warning introduced in #5235.
2016-06-07 14:14:41 -07:00
Minh Nguyễn
b761aad4e6 [ios] Bring annotation view to front when selected
Fixes #991.
2016-06-07 00:53:10 -07:00
Minh Nguyễn
b3d9e125b1 [ios] Avoid adding icon when relocating annotation
Fixed an issue that caused a default annotation icon to appear beneath an annotation view when relocating the annotation.
2016-06-06 16:00:45 -07:00
Minh Nguyễn
62149410fa [ios, osx] Ignore multipoints
Ignore multipoints (as opposed to polylines and polygons) when adding annotations, just like we ignore multipolylines, multipolygons, and shape collections.

In osxapp, break multipoint features into points before adding them as annotations.
2016-06-06 15:40:52 -07:00
Minh Nguyễn
d3fe798493 [ios] Split out MGLMapViewDelegate into separate header 2016-06-06 01:28:04 -07:00
Minh Nguyễn
1f622fe48f [ios] Made annotation views accessible
Annotation views now serve as their own accessibility elements. The developer’s own subclass of MGLAnnotationView can customize the view’s accessibility frame and/or path to more accurately reflect the visual hit target.
2016-06-03 15:13:21 -07:00
Minh Nguyễn
1fdda914e0 [ios] Corrected annotation view accessibility frame
Corrected the accessibility frames of annotation views to match the views’ bounds instead of the bounds of the default annotation image (which could be empty if no default GL point annotation has been added).

Fixes #5038.
2016-06-03 15:13:17 -07:00
John Firebaugh
c902f9098b [core] Rationalize naming for style-related code 2016-06-02 14:51:39 -07:00
John Firebaugh
d7e1ecd19e [core] Generalize Map::{add,remove}CustomLayer 2016-06-02 14:51:39 -07:00
John Firebaugh
0fba70d5a8 [all] Rationalize annotation API 2016-06-01 17:37:01 -07:00
John Firebaugh
8985b1311b [core] Use geometry.hpp types for shape annotations 2016-06-01 17:36:50 -07:00
Jesse Bounds
d9c6181f34 [ios] Add annotation container view (#5194)
Add a container view to hold annotations. This gets around a performance
issue with `UIView:addSubview:` where adding views is N^2. It helps
annotation views avoid cutting into callout views when the annotation
views are transformed to be "flat".
2016-06-01 17:36:07 -07:00
Jesse Bounds
2ab782b30e [ios] Make turnstile send guard based off of calendar day (#5180)
This improves the turnstile send time guard so that instead of guarding
against sending a turnstile event once per 24 hours it guards using
a calendar day. This means that, all else being equal, a turnstile
can be sent once per day in the same session assuming there is a map
load event in that session. A turnstile will always be sent for a map
load at the start of a session.
2016-05-31 08:49:10 -07:00
Minh Nguyễn
974e669698 [ios, osx] Ignore compound shape types as annotations
Ignore any multipolyline, multipolygon, or shape collection object passed into -addAnnotation: or -addAnnotations:. Previously, these methods broke apart the compound shape into its constituent shapes in order to recursively add them to the map. But that broke assumptions about a one-to-one correspondence between annotations and their contexts during selection and deletion.
2016-05-27 21:42:39 -07:00
Minh Nguyễn
de905ab64c [ios, osx] Holes in polygons
MGLPolygon (and by extension MGLMultiPolygon) now supports interior rings. The data is preserved in feature querying results, and interior rings are respected when adding polygon overlays to the map.

Fixes #1729.

[ios, osx] Updated changelog
2016-05-27 21:42:38 -07:00
Minh Nguyễn
c6683ee1d3 [ios, osx] Feature querying; complex geometry classes
Added methods to MGLMapView that return the rendered features at a visible point or within a visible rectangle on the map, optionally restricted to a set of layers, plus voluminous documentation.

Added several new geometry classes corresponding to distinct geometry types supported by geometry.hpp. Added parallel “feature” classes to represent these geometries along with tags (IDs) and attributes (properties) from the source.

Grouped classes in the Foundation and SDK groups by theme.

In iosapp, dropped pins’ callout views now display the name of the topmost named feature at that point.

In osxapp, a long press on the map highlights the features under the cursor. Dropping a pin via the menu or context menu item shows the usual dropped pin, but the pin’s title is now the name of a feature under the cursor, if available, rather than “Dropped Pin”.

Fixes the iOS/OS X side of #352.
2016-05-27 21:42:31 -07:00
Jesse Bounds
c9520713ca [ios] Update telem domain and certs (#5181)
Change domain from api -> events
Replace old certs with new ones with the same name. The new certs
have an expiry that is further out.
2016-05-27 18:43:39 -07:00
Jesse Bounds
6ec9295ab5 [ios] Force update from display link when display link is created. (#5164)
This forces the call of the map view's display link target when the
display link is created. When a map view is shown the first time
this is not required. However, if the display link was torn down
and then recreated due to the map view being removed / obscured in the
view hierarchy the map view delegate may expect to be informed when
the map view did finish loading the map when it is shown again.

This adds a call to `updateFromDisplayLink` just after a display link
is created which helps trigger a full refresh of the map in the sense
that all delegate methods get exercised including
`mapViewDidFinishLoadingMap`.
2016-05-27 17:37:09 -07:00
Jesse Bounds
c90f51a1a9 [ios] Add annotation view scaling (#5085)
This adds an option to MGLAnnotationView so that a developer can control
how their annotation views scale in size as they approach the top of
the map view (along the Y axis). The size change is also affected by
the pitch (tilt) of the map view. If there is no tilt then scaling
is not performed. As the map is tilted scaling is gradually applied.

This turns the MGLAnnotationView implementation into an Objective C++
class so that SDK constants from C++ files can be used.

The new behavior is enabled by default to maintain consistency with
annotations backed by GL sprites. The MBXViewController redundantly
sets the new property as an illustration of use.
2016-05-26 23:10:02 -07:00
Tore Halset
f3ec50da12 overide canBecomeFirstResponder to return YES to be able to use UIMenuController on the map (#5156) 2016-05-26 07:43:53 -07:00
Jason Wray
842de0e859 [ios] Fix points/shapes typo that caused crash (#5142)
https://github.com/mapbox/mapbox-gl-native/pull/5097 introduced different arrays for points and shapes, but only ever attempted to use the points array. Adding a shape would crash.
2016-05-25 17:48:51 -04:00
Minh Nguyễn
2865e7d35c [ios, osx] Added wireframe debugging mask
Added an option to MGLMapDebugMaskOptions for the new wireframe debugging mode and UI in the demo applications for toggling it.
2016-05-23 11:51:05 +03:00
Minh Nguyễn
645dd25d0b [ios, osx] Fixed crash adding mixture of points and shapes
Fixes #5096.
2016-05-22 23:49:11 -07:00
frederoni
a220efcae6 [ios] Allow annotation views to be flattened (#5067)
* [ios] wip flatten annotation view

* [ios] wip flatten annotation view

* [ios] naming conventions

* [ios] removed unused property
2016-05-18 17:03:08 -07:00
frederoni
e8ea7483a7 [ios] Added centerOffset to MGLAnnotationView (#5062)
* [ios] Added centerOffset to MGLAnnotationView

* [ios] Reposition immediately after changing the centerOffset

closes #5059
2016-05-18 09:47:54 -07:00
Jason Wray
0d5d2a923b [ios] Improve telemetry server URL validation (#5022)
- Validate that test server URL actually has a reasonable value.
- Refactor `baseURL` and `testServerURL` to use NSURL.
2016-05-13 21:46:13 -04:00
Jesse Bounds
1ee14915f8 [ios] Add method documentation for view based annotations. 2016-05-13 15:53:04 -07:00
Jesse Bounds
fb759e8475 [ios] Refactor of annotation view updates
This change eliminates the call to the problematic
`annotationTagsInRect:` by using the annotation views themselves
and the map view to check if a view is visible or not.
2016-05-13 15:52:53 -07:00
Jesse Bounds
39669243b7 [ios] Introduce MGLAnnotationView and support for view annotations
Add an UIView subclass that can be used as the base class for all
client provided UIViews for annotations.

Teach MGLMapView to be able to display annotation views over the map if provided by the client delegate. For now, if the delegate provides a UIView then it will be used. If not, the map view will fall back to the old strategy of using GL annotations with an image provided by the delegate or a default image if not.
The map keeps a reuse queue and will store annotation views that are panned
offscreen in the queue if the application developer supplied a reuse queue identifer. The views in the queue are reused when more annotation
views are required. This view reuse provides a performance gain when many
annotations are shown and most of them are offscreen.

iosapp now implements the new delegate method to supply
a native view.

Add a playground to the workspace to facilitate experimentation
with new features. A playground is capable of importing frameworks if it
exists in the same workspace that builds the imported framework. The
initial playground demonstrates annotation views.

This also fixes a crash due to nullptr in annotations array If the `annotations` method is called while the user dot's callout view was showing, the userdot annotation is represented as null in the annotation context map. This
caused a crash when the null pointer was attempted to be converted
into an NSArray via C array. This protects against this bug by filtering out such a null annotation.
2016-05-13 15:51:40 -07:00
Bruno de Oliveira Abinader
c13dd32242 [core] Added Viewport mode
Satisfies embedding platforms that requires the viewport coordinate
systems to be set according to its standards e.g. viewport mirrored
vertically.
2016-05-11 15:48:51 +03:00
Brent W
348cfaab12 [ios] fix potential for very slow animations of user location dot (#4997)
fix logic error that could cause user location to animate extremely slowly if there is a significant time passing between location updates
2016-05-10 16:55:00 -07:00
Minh Nguyễn
b3d4a5cbf8 [ios, osx] Find nearby annotation when not persisting query
Fixed an issue that made the osxapp context menu only apply to the right-clicked pin after first selecting the pin. This also happened to be a latent bug in the iOS implementation.
2016-05-09 13:13:31 -07:00
Minh Nguyễn
2ec95bc490 [ios, osx] Renamed version constant, linked to more info
Renamed MGLStyleCurrentVersion to MGLStyleDefaultVersion to emphasize the constant’s role as an indicator of the default version used by SDK classes, which may be behind depending on release schedules. In the documentation for each style URL method, include the actual version number instead of the constant. In unit tests, verify that this documentation is in sync with the constant.

Link each style URL method’s documentation to a forthcoming webpage on mapbox.com that describes the style in rich detail.
2016-05-06 11:06:52 -07:00
Minh Nguyễn
2a4eeadb29 [core, ios, osx] Version default style URL APIs; deprecated Emerald
Updated default styles from v8 to v9. Deprecated the MGLMapView class methods in favor of new methods that take a version parameter. Deprecated Emerald outright in favor of Outdoors. Replaced usage of the unversioned MGLStyle methods with the corresponding versioned methods and MGLStyleCurrentVersion to ensure consistency.

Expanded MGLStyle unit tests to also assert that MGLStyle has the right number of style URL methods and that they’re all public. Linked the OS X SDK unit test bundle to libmbgl-core.a. Removed an unnecessary dependency on osxapp.

Replaced Emerald with Outdoors in iosapp and osxapp.

Fixes the iOS and OS X side of #4577 and #4702.
2016-05-06 10:57:54 -07:00
Minh Nguyễn
d28b6f3719 [ios, osx] Avoid recomputing tile cache size on every redraw
The tile cache size is only recomputed when an input changes.

Fixes #4026.
2016-05-06 08:47:18 -07:00
John Firebaugh
ce2a06e677 [core] Privatize math.hpp and vec.hpp 2016-05-05 11:16:57 -07:00
John Firebaugh
10e522d10b [core] Privatize various util headers (#4945) 2016-05-04 14:09:51 -07:00
Minh Nguyễn
9a280b8d9d [ios] Corrected map accessibility value
Corrected the English override strings for the map view’s accessibility value. Prior to this change, the accessibility value would say “0 annotation” instead of “0 annotations” for some reason.

The zoom level in the map view’s accessibility value is off by two.
2016-05-04 02:23:20 -07:00
Jason Wray
963ae18893 [ios] Fix analyzer's nullability complaints
- Redefine as local variables
- Check/assert that these local variables are not nil
2016-04-29 18:04:22 -04:00
Minh Nguyễn
51cd97861c [ios] Announce zoom level, visible annotations after zooming
Announce the zoom level and number of visible annotations after zooming using VoiceOver’s swipe up or swipe down gesture.

Works toward #4821.
2016-04-26 16:47:04 -07:00
Minh Nguyễn
8d5a6b515f [ios] Only post layout change notifications when focused
Constantly posting accessibility layout change notifications on every location change made it very difficult to stay focused on an accessibility element, be it the user dot or some other element. Now we only post the notification when the user dot is focused, user tracking mode is off (so the user dot actually has a chance to move around), and the application is active (not in the middle of application switching).
2016-04-26 14:19:10 -07:00
Minh Nguyễn
193a843013 [ios] Fixed ℹ️, user dot accessibility
The user location annotation view is created lazily, so if the user dot isn’t within view at launch, it doesn’t exist by the time UIKit first queries MGLMapView for child accessibility elements. This caused console spew about missing accessibility elements and prevented the ℹ️ from being visible to XCUITest.
2016-04-26 14:19:05 -07:00
Minh Nguyễn
27f77b6bfa [ios] Hide compass from VoiceOver when pointing north
Fixes #4820.
2016-04-26 00:16:20 -07:00
Jason Wray
8ce0fb4739 [ios] Update frame size when changing dot/puck mode
- Keeps the same center point
- `updateFrameWithSize:` does not take CGSize because there is not yet
  support for non-square user location annotations
2016-04-25 17:00:43 -04:00
Minh Nguyễn
d9a2a845de [ios] Added accessibility labels, hints, gestures
Fixed an issue where the “return to map” accessibility element lacked a label. Always update the title and subtitle of an annotation accessibility element, in case the title or subtitle changes from one showing to the next.

Added a hint for annotations. Use declarative rather than imperative for hints.

Marked the map view and its annotations as adjustable so that swiping up and down with VoiceOver zooms out and in, respectively.

Added accessibility values to toolbar buttons in iosapp.
2016-04-25 00:24:35 -07:00
Minh Nguyễn
7cc3928a19 [ios] Made annotation callouts accessible
Via nfarina/calloutview#84, SMCalloutView is now accessible. Activating a focused annotation now shows its callout view and focuses its left accessory view, if present, or the title view. There is a “return to map” accessibility element for dismissing the callout view and restoring focus to the annotation on the map.
2016-04-25 00:18:57 -07:00
Minh Nguyễn
9d3269eaa3 [ios] Restored user dot accessibility
Put the user dot back into rotation as an accessible element.
2016-04-25 00:18:06 -07:00
Minh Nguyễn
babc43ea62 [ios] Made annotations accessible
Lazily create and cache accessibility elements for visible annotations as UIAccessibility asks about them.

Sort the annotations’ accessibility elements by the annotations’ distance from the logical center (the center after accounting for padding, or the user dot when user tracking mode is on).

Updated the changelog.

Fixes #1493.
2016-04-25 00:17:02 -07:00
Minh Nguyễn
893a777a2f [ios] Made compass and user dot accessible
Made the compass behave like a button when visible. Added accessibility values and hints. The compass’s accessibility value uses the compass direction formatter. Turned off direct interaction with the map because it obscures the ornaments.

The user dot now reports the current coordinates. Its accessibility label now reflects its annotation’s title instead of the hardcoded label “User location”. (It’d be weird to address the VoiceOver user as “user”.)
2016-04-25 00:16:28 -07:00