Commit Graph

9284 Commits

Author SHA1 Message Date
Jesse Bounds
ce1d9ff5ee [ios, macos] Silence -Wc++11-narrowing warning in open gl layer (#7355) 2016-12-09 09:58:44 -08:00
Minh Nguyễn
fe53af7de0 [ios, macos] Source-driven attribution (#5999)
* [ios, macos] Source-driven attribution

Refactored MGLSource initialization. Implemented a new private class, MGLAttributionInfo, that parses an HTML attribution string from TileJSON and stores the resulting structured data. Added methods to MGLTileSet and MGLStyle to aggregate MGLAttributionInfos.

On macOS, update the attribution view as soon as the source attribution changes. On iOS, fetch the current attribution information when displaying the action sheet.

Removed hard-coded attribution strings.

* [macos] Respect inline formatting in attribution HTML

Apply a default font and color to attribution HTML as it is imported into an attributed string. Pass the attributed string into MGLAttributionButton as is, without stripping formatting. Avoid overriding the font and color after importing the HTML, in case these attributes are explicitly specified rather than intrinsic to a hyperlink.

Constrain the top of the attribution view to all the attribution buttons, in case one of them needs additional headspace.

* [ios, macos] Display unlinked attribution strings

Unlinked attribution strings are represented on macOS as buttons that have the default cursor and do nothing when clicked. On iOS, they are action sheet buttons that do nothing but dismiss the action sheet.

* [macos] Fixed random Auto Layout exception

Auto Layout randomly finds itself unable to satisfy constraints when updating attribution, due to some spurious constraints between attribution buttons. Regenerate the entire attribution view every time the source attribution changes.

* [ios, macos] Thoroughly dedupe attribution infos

Also added a test to verify parity with the GL JS implementation. This implementation avoids sorting.

* [ios, macos] Trim whitespace from attribution strings

Also added parsing tests.

* [ios, macos] Added attribution parsing tests for styles

Included an emoji test to ensure that attribution strings are interpreted as UTF-8, to avoid mojibake. Included a test of removing the underline from a leading copyright symbol.

* [ios, macos] Derive feedback link from source

MGLAttributionInfo now detects feedback links in the attribution HTML code, and it is responsible for tailoring the feedback URL to the current viewport.

Removed the hard-coded feedback action from the attribution sheet on iOS in favor of a source-derived feedback title and URL. Moved the feedback action from macosapp to MGLMapView; applications are now expected to hook an Improve This Map menu item to an MGLMapView action.
2016-12-08 17:43:17 -08:00
Fredrik Karlsson
89d4c40d92 [ios, macos] renamed raster-hue-rotate 2016-12-08 11:36:39 +01:00
Jesse Bounds
01ff94a6eb [ios, macos] Warn about special characters in predicates (#7317) 2016-12-07 14:06:02 -08:00
Jesse Bounds
497953c34e [ios, macos] Fix typo in exception name for style source identifier (#7315) 2016-12-07 10:47:06 -08:00
Fredrik Karlsson
508f020eb5 Prevent stopless functions (#7309)
* [ios, macos] prevent stopless functions

* [ios, macos] removed unused bridging header and fixed naming
2016-12-07 17:19:15 +01:00
Fredrik Karlsson
3b7e98d0b1 [ios, macos] fixed compiler warnings 2016-12-07 12:52:59 +01:00
Minh Nguyễn
178130267e [ios, macos] Corrected -setNeedsDisplay documentation
Followup to #7250.
2016-12-07 00:31:30 -08:00
Minh Nguyễn
a39f53df22 [ios, macos] Migrate MGLCustomStyleLayerAdditions to style layer API (#7250)
* [ios, macos] Replaced custom style layer API with MGLOpenGLStyleLayer

Replaced the custom style layer API on MGLMapView with an equally unsupported MGLOpenGLStyleLayer API that nonetheless is consistent with the broader runtime styling API and is compatible with macOS.

Fixed an unrecognized selector crash when wrapping a layer of unrecognized type coming from mbgl.

* [macos] Added lime green layer demo to macosapp

Reprised the demo removed from iosapp in #5091.

* [ios, macos] Rationalized MGLOpenGLStyleLayer API

MGLStyle now strongly references any MGLOpenGLStyleLayer object that’s added to it, in order to prevent pointers from going stale and make it easy for layer drawing code to get more information about the map view. Replaced the MGLOpenGLStyleLayer callback blocks with overridable instance methods. Added internal documentation for each method. Subclassed MGLOpenGLStyleLayer as LimeGreenStyleLayer inside macosapp.

Consolidated -addToMapView: into -addToMapView:belowLayer: to ensure that MGLRedundantLayerException gets raised even if the layer is being inserted rather than added to the bottom of the stack.

* [core] Clarified that rendering happens on the main thread

* [ios, macos] Fixed removing and re-adding MGLOpenGLStyleLayer

Don’t allow index-based layer removal to circumvent -removeFromMapView:, which MGLOpenGLStyleLayer relies on to synchronize the style’s array of MGLOpenGLStyleLayers. When obtaining an MGLOpenGLStyleLayer, get the instance already added to the style instead of creating a new one to wrap the underlying CustomLayer.
2016-12-07 00:01:11 -08:00
Minh Nguyễn
4c2aec2355 [ios, macos] More ways to reshape an MGLMultiPoint (#7251)
* [ios, macos] Completed API for mutating multipoints

Added the complete set of methods for mutating the vertices of an MGLMultiPoint. Also rewrote MGLMultiPoint documentation to refer to vertices instead of points.

* [ios, macos] Removed inaccurate MGLOverlay commentary

This paragraph is full of references to features that exist in MKOverlay but not MGLOverlay.

* [ios, macos] Lazily compute multipoint bounds

Invalidate the bounds whenever the coordinates change, but don’t recompute the bounds until they’re requested. Simplified -intersectsOverlayBounds: for immutable overlay classes.

Added a utility function for testing whether two MGLCoordinateBounds intersect, based on mbgl::LatLngBounds::intersects().

Removed unused color conversion code.
2016-12-06 23:36:55 -08:00
Minh Nguyễn
9f9422deb8 [ios] s/iconSize/iconScale/
Followup to #7310.
2016-12-06 21:28:04 -08:00
Minh Nguyễn
88f91a48ae [ios, macos] Template images as style images
Convert template images to SDF icons and back when storing them as style images.
2016-12-06 16:20:14 -08:00
Minh Nguyễn
e6d51c384d [ios, macos] Note corresponding style spec properties
Documentation for attributes whose names we’ve overridden now mention the original style specification property name, with a link to the style specification documentation for the property.
2016-12-06 22:18:03 +01:00
Fredrik Karlsson
903246b256 [ios, macos] renamed dasharray and icon size 2016-12-06 22:18:03 +01:00
Fredrik Karlsson
dc2dc31c0b [ios, macos] MGLGeoJSONSource can now be initialized with any shape 2016-12-06 13:59:56 +01:00
Minh Nguyễn
9456bec172 [test] Fixed Map-GetImage
Followup to #7096.
2016-12-05 18:48:00 -08:00
Roman Blum
1045934d5e [core, ios, macos] Add image accessor to MGLStyle (#7096)
* [core] Add interface to get image from sprite atlas

* [tests] Add tests for Map::getImage

* [ios, macos] WIP: get MGLImage for name from style

* [ios, macos] Fixed -imageForName:

Convert from sprite images to platform images using the existing encodePNG() function, which is also used for printing. Allow -imageForName: to return nil without an assertion failure. Added a basic test.
2016-12-05 17:16:13 -08:00
Jesse Bounds
5579e67804 [ios] Round horizontal accuracy 2016-12-05 15:10:38 -08:00
John Firebaugh
4a61fcdafb [node] Update brew package name 2016-12-05 15:09:49 -08:00
Fredrik Karlsson
440e06c112 [ios] keep callout view open when panning 2016-12-05 11:42:31 +01:00
Minh Nguyễn
36d93b747e [ios] Removed duplicate changelog entries 2016-12-05 00:27:04 -08:00
Jesse Bounds
9eb7f88b2c [ios, macos] Update MGLStyle API documentation with warnings for dupes
This adds notes to the methods for adding sources and layers to warn
of the hazards of using duplicate instances or identifiers.
2016-12-02 14:21:05 -08:00
Jesse Bounds
179e9c610f [ios, macos] Consolidate tests of MGLStyle addSource in MGLStyleTests
This replaces the integration test of `addSource` when duplicate
identifiers are used in `MGLSourceTests` with a more direct unit test
in the style class's unit test file `MGLStyleTests`. Although tests of
the case where the same instance are actually integration tests where
the source instance itself throws, it is easier to test all of this
functionality in one place using the public facing MGLStyle API.
2016-12-02 14:21:05 -08:00
Jesse Bounds
1db0a96927 [ios, macos] Raise NSException if layer or source added more than once
When MGLSource and MGLLayer instances are added to the style, they lose
ownership of their std::unique_ptr<T> after it is moved to the mbgl
level. Subsequent attempts to add such instances result in a C++
exception.

This adds logic in the Darwin platform to raise a NSException if the
source and layer addToMapView methods are called more than once and the
pointer is invalid. In addition, the documentation in MGLStyle for
addSource: and addLayer: has been update to warn developers to avoid
adding the same instance twice and, for that matter, instances with the
same identifier.
2016-12-02 14:21:05 -08:00
Jesse Bounds
2db31be8bc [ios, macos] Rename MGLMapViewTests back to MGLStyleLayerTests 2016-12-02 13:03:05 -08:00
Ivo van Dongen
37026a14ff [ios, macos] handle duplicate source error 2016-12-02 11:39:16 -08:00
Ivo van Dongen
d44d1c8401 [ios, macos] renamed MGLStyleLayerTests to MGLMapViewTests 2016-12-02 11:28:34 -08:00
Ivo van Dongen
2c4e7ae70f [core] guard against duplicate source id’s 2016-12-02 11:25:30 -08:00
Jesse Bounds
8317a11a10 [ios] Update changlog for ios-v3.3.7 2016-12-01 17:02:12 -08:00
Jesse Crocker
5dd71d3c30 [ios, macos] Make tap gesture recognizer fail if it doesn’t do anything (#7246)
* Make tap gesture recognizer fail if it doesn’t do anything.

* fix typo

* Use the right nullable

* update changelog

* Make single click gesture recognizer fail if it doesn’t select an annotation

* fix changelog typo

* Remove singleTapGestureRecognizer from public header
2016-12-01 11:50:20 -08:00
Jesse Bounds
b2c2d4ebc4 [ios, macos] Update style predicate documentation
Note the support of CONTAINS and the lack of support for case and
diacritic operator modifiers.
2016-12-01 08:57:41 -08:00
Jesse Bounds
7e9457214a [ios, macos] Add back support for CONTAINS operator
This reverts commit 6877e3efe7.
2016-12-01 08:57:41 -08:00
Jesse Bounds
dbb520662d [ios, android] Move der files to ios platform
.der files are used only by the iOS platform for SSL pinning. This
moves them out of the `platform/default/resources` directory and into
`platform/ios/resources`. The make configuration for Android is
updated so that it stops attempting to copy the files at all.
2016-11-30 16:19:22 -08:00
Jesse Bounds
e9504912dc [ios] Use new pinning cert for staging
This updates the cert for the staging environment. It also adjusts the
telem implementation to send along the horizontal accuracy for each
location event and removes the previous battery level gathering logic.
2016-11-30 16:19:22 -08:00
Jesse Bounds
37a087c675 [ios, macos] Avoid unsafe cast when removing style layers (#7227)
This updates the code generation for style layers to add a test to check
that the style object returned from mbgl can be safely cast into the
expected type so ownership can be returned to the caller when removing
layers.

This scenario was previously possible if a layer of type T was
added before a layer of type U but both layers shared the same
identifier. In that case, if the pointer to the second layer of type U
was used to remove a layer, a runtime exception would occur since mbgl
returns the layer with type T (the first one added).

Now, an exception will still occur if layers with the same
identifier are manipulated as described above but it is done as part of
a validation check for all public style layer methods at the Darwin
platform level. The NSException attempts to warn developers about using
and reusing style identifiers to avoid this issue in the first place.
2016-11-30 11:59:29 -08:00
Jesse Bounds
ba775404d8 [ios, macos] Add notes to APIs that rely on style and source ids (#6886)
Update documentation to make the implications of identifiers clearer.
2016-11-30 09:26:21 -08:00
Fredrik Karlsson
17db5210bf [ios, macos] rename style spec properties 2016-11-30 11:36:39 +01:00
Minh Nguyễn
4096544188 [ios, macos] Marked C array parameters as const
Fixes #7214.
2016-11-29 22:47:30 -08:00
Minh Nguyễn
336d48df48 [ios, macos] Fixed spurious offline storage test failure
Even if the expectation is immediately fulfilled, we still have to wait for it to be fulfilled, because the expectation only gets unregistered after waiting. The zombie expectation was fulfilling a stricter expectation in a test method.
2016-11-29 13:36:55 -08:00
Jesse Bounds
d830c48e4a [ios, macos] Refcount view activations (#7208)
This adds a ref count to guard against calling activate after it has
already been called. This can happen when a layer is added during
certain map lifecycle methods like MapChangeWillStartRenderingFrame
that also triggers activation. This also protects against issues
related to a deactivation of the context happening in an inner scope
while an outer scope is still expecting to be able to use the context.
2016-11-29 08:56:59 -08:00
Minh Nguyễn
83e134eb9f [macos] Added option to localize labels
Added a setting to macosapp to change all symbol layers in the current style to use the preferred language if available. If the setting is off, change all symbol layers to use local languages.
2016-11-28 15:45:44 -08:00
Minh Nguyễn
f611355912 [macos] Name custom style in toolbar
Display the custom style’s name in the Style toolbar button.
2016-11-28 15:45:44 -08:00
Minh Nguyễn
992726ab49 [macos] Added Layers sidebar
Added a sidebar to the main document window in macosapp that lists the layers in the current style and updates whenever the style changes or a layer is added or removed programmatically. Display an icon beside each layer in the sidebar that indicates the kind of layer. Double-click a layer or layers to toggle their visibility, which is an undoable action. Added a menu item and toolbar button to toggle the Layers sidebar. Added a context menu for toggling visibility of and deleting layers selected in the Layers sidebar.

Checked in the original SVGs for layer icons.
2016-11-28 15:45:43 -08:00
Minh Nguyễn
03a2dbe361 [macos] Avoid first responder action name conflict
Fixed a crash that often occurred when switching styles. MGLMapView was ahead of MapDocument in the responder chain, so calls to -setStyle: were going to MGLMapView’s private -setStyle: method. The sender was being passed in the first parameter instead of an MGLStyle method.
2016-11-28 15:45:43 -08:00
Minh Nguyễn
9fac640bf3 [ios, macos] Key-value compliance for MGLStyle
Replaced -[MGLMapView style] with a property. Keep the MGLStyle object around for the lifetime of the style.

Bracket changes to layers in willChange and didChange calls. The built-in point annotation layer is added after the style is finished loading but before the map is finished loading. Cause a second wave of change notifications to go out, about both sources and layers. Issue change notifications for style layers when shape annotations are added or removed.
2016-11-28 15:45:43 -08:00
Minh Nguyễn
850b70ff91 [core, ios, macos] Added layers and sources properties to MGLStyle
Added new layers and sources properties to MGLStyle that contain all the style’s layers and sources, respectively. These properties are KVC-compliant with all the mutable to-many methods. Layers are ordered from topmost to bottommost, for consistency with Cocoa APIs where front/first means top and back/last means bottom.

Also added storage for mbgl::style::Source in MGLSource proper for wrapping AnnotationSource. Until the style finishes loading, its name property is set to nil.

Fixes #6003.
2016-11-28 15:45:37 -08:00
Minh Nguyễn
f71dd14bb7 [ios, macos] Reorganized MGLStyle 2016-11-23 16:02:18 -08:00
Minh Nguyễn
767044420d [ios, macos] Added debug descriptions for runtime styling classes 2016-11-23 16:02:17 -08:00
Jesse Bounds
67e079f726 [ios, macos] Fix integer formatting in formatted exception strings (#7173) 2016-11-23 12:21:52 -08:00
Jesse Bounds
75666e5b53 [ios, macos] Use namespaced property names in style NSValue category (#7171) 2016-11-23 08:20:47 -08:00