@@ -4503,38 +4503,35 @@ <h5>Conclusion</h5>
4503
4503
< section id ="capability-implement-a-custom-control " data-ucr-role ="capability ">
4504
4504
< h4 > Implement a custom control</ h4 >
4505
4505
< p >
4506
- A custom control is a user interface element that is
4507
- integrated closely with the map's own user interface, and is
4508
- under the control of the map once it has ben added.
4506
+ Controls are user interface elements that enable interaction with the map.
4507
+ Map implementations typically provide a number of default controls supporting interactions such as zooming
4508
+ and switching layers.
4509
+ </ p >
4510
+ < p >
4511
+ A map implementation will typically provide the developer with various options for configuring controls.
4512
+ This will include such capabilities as adding and removing controls, showing or hiding them,
4513
+ and being notified of changes in their state.
4514
+ It is also necessary to provide support for controlling the positioning of controls,
4515
+ to avoid the situation where two controls occupy the same position on the map's UI.
4516
+ </ p >
4517
+ < p >
4518
+ Developers may wish to implement additional controls, either replacing the functionality of the map's default controls,
4519
+ or adding new functionality.
4520
+ Map implementations should provide APIs to support such custom controls,
4521
+ allowing them to integrate fully with the map at a level that is on a par with the map's own controls.
4509
4522
</ p >
4510
4523
< p class ="issue discussion " data-number ="57 ">
4511
4524
Discuss this section on GitHub.
4512
4525
</ p >
4513
4526
4514
4527
< h5 > Existing implementations</ h5 >
4515
4528
< p >
4516
- A custom control is a JavaScript object or a DOM element
4517
- that satisfies the API's requirements for it to be
4518
- integrated with the map.
4519
- Those requirements vary across APIs.
4520
- Generally, it is expected that a single DOM element
4521
- containing whatever other elements constitute the control UI
4522
- will be provided by the control.
4523
- In some cases the DOM element is passed to the API directly;
4524
- in others, a JavaScript object is passed to the API, which
4525
- is required to implement a method that returns the control's
4526
- containing DOM element.
4527
- Styling of the elements within the control is the
4528
- responsibility of the implementor.
4529
- </ p >
4530
- < p >
4531
- Assuming the API requirements are satisfied, the behaviour
4532
- and rendering of the control are then the responsibility of
4533
- the implementation.
4534
- Typically, a custom control will listen to events from the
4535
- DOM, or the map, or both.
4536
- In response to those events, it will then update the state
4537
- of the map, update its own representation, or both.
4529
+ Support for controls varies widely among existing map implementations.
4530
+ It is generally the developer's responsibility to create a suitable DOM construct,
4531
+ styled with CSS and augmented with JavaScript to provide behaviour, for use as a control.
4532
+ But though some implementations specify detailed APIs which controls should support
4533
+ in order to be properly integrated with the map, others provide minimal support and expect the
4534
+ developer to take full responsibility for responding to control lifecycle transitions.
4538
4535
</ p >
4539
4536
< dl data-ucr-role ="implementation-notes ">
4540
4537
<!-- Use dt elements to name the implementation, using the id string to create an auto-link.
@@ -4543,24 +4540,57 @@ <h5>Existing implementations</h5>
4543
4540
List full implementations first.
4544
4541
Group implementations (multiple dt for the same dd) when they have the same support.
4545
4542
-->
4546
- < dt > google-maps-api</ dt >
4547
4543
< dt > mapbox-gl-api</ dt >
4548
4544
< dt > leaflet-api</ dt >
4549
4545
< dt > open-layers-api</ dt >
4546
+ < dt > tomtom</ dt >
4550
4547
< dd > < a > full support</ a > :
4551
- These APIs all define requirements for a JavaScript object or DOM element
4552
- to be able to be used as a custom control.
4548
+ < p >
4549
+ All of these implementations fully support the concept of controls,
4550
+ including support for control implementations to be notified when they are added to or removed from the map,
4551
+ so they can update their own internal state accordingly.
4552
+ They also allow controls to request their desired positioning within the map's UI,
4553
+ and will position controls using sensible defaults if developers choose not to implement that capability.
4554
+ </ p >
4555
+ < p >
4556
+ MapBoxGL specifies an interface to which controls are expected to conform.
4557
+ The map API provides methods for adding and removing controls to and from the map UI.
4558
+ </ p >
4559
+ < p >
4560
+ Leaflet, TomTom (which uses Leaflet), and OpenLayers provide base classes which controls extend,
4561
+ along with map methods for adding and removing controls.
4562
+ OpenLayers also exposes its control collection directly.
4563
+ </ p >
4564
+ </ dd >
4565
+ < dt > google-maps-api</ dt >
4566
+ < dd > < a > supported, with limitations</ a > :
4567
+ < p >
4568
+ While Google Maps supports the adding and removing of controls and the specifying of their placement
4569
+ within a number of predefined areas within the map's UI,
4570
+ there is no specific interface to which they are expected to conform.
4571
+ </ p >
4553
4572
</ dd >
4554
4573
< dt > bing-maps-api</ dt >
4574
+ < dd > < a > partial support</ a > :
4575
+ < p >
4576
+ Bing Maps expects controls to be implemented as a type of overlay.
4577
+ It provides no particular support for controls beyond that, not even for positioning them within the map UI,
4578
+ which is left to the developer to achieve using CSS positioning.
4579
+ </ p >
4555
4580
< dt > apple-mapkit-js-api</ dt >
4556
- < dd > < a > supported, with limitations</ a > :
4557
- Items having the form and behaviour of custom controls can
4558
- be implemented in the form of overlays, but there is no facility for
4559
- distinguishing such controls from other overlays.
4581
+ < dd > < a > no support</ a > a> :
4582
+ < p >
4583
+ Apple MapkitJS does not provide an interface that can be implemented to create a custom control,
4584
+ nor does it have any generic mechanism for adding and removing controls beyond those provided.
4585
+ </ p >
4560
4586
</ dd >
4561
4587
< dt > d3-geographies-api</ dt >
4562
4588
< dd > < a > not applicable</ a > :
4563
4589
<!-- details about what is/isn't supported -->
4590
+ < p >
4591
+ Although d3 supports a variety of user interactions, the concept of a user interface presenting a collection
4592
+ of controls to the user is not part of the library.
4593
+ </ p >
4564
4594
</ dd >
4565
4595
</ dl >
4566
4596
@@ -4569,7 +4599,9 @@ <h5>Supported use cases</h5>
4569
4599
4570
4600
< h5 > Uses beyond mapping</ h5 >
4571
4601
< p >
4572
- ToDo
4602
+ As controls are explicitly intended as part of the map's user interface,
4603
+ further uses for the concept might be found in other cases
4604
+ where complex interactive content is presented by an element, such as adding controls to media containers.
4573
4605
</ p >
4574
4606
4575
4607
< h5 > Related web specifications</ h5 >
@@ -4585,7 +4617,10 @@ <h5>Conclusion</h5>
4585
4617
See examples.
4586
4618
-->
4587
4619
< p >
4588
- Based on the limited data, we are < a data-ucr-role ="conclusion "> undecided</ a > about whether this should be a requirement.
4620
+ It might seem that, as controls are implemented using existing interactive HTML elements,
4621
+ there is no pressing need for them to be supported by additional APIs.
4622
+ However, the need for them to be closely integrated with a map's own UI, state, and lifecycle
4623
+ suggests that this functionality is a < a data-ucr-role ="conclusion "> requirement</ a > for modern web maps.
4589
4624
</ p >
4590
4625
< ul data-ucr-role ="conclusion-notes ">
4591
4626
<!-- bullet-point notes summarizing implementation details / blocking issues.
@@ -5435,15 +5470,44 @@ <h5>Conclusion</h5>
5435
5470
</ section >
5436
5471
5437
5472
< section id ="capability-map-events " data-ucr-role ="capability ">
5438
- < h4 > Subscribe to map move events</ h4 >
5473
+ < h4 > Subscribe to notifications of map events</ h4 >
5474
+ < p >
5475
+ A web application embedding a map will commonly need to respond to changes in the state of the map,
5476
+ whether as a result of user activity or from other causes,
5477
+ so that it can update its own internal state and user interface as necessary to remain consistent with the map view.
5478
+ At a minimum, any change of the area displayed by the map needs to be notified to the application.
5479
+ In practice, it is usually desirable for other high-level events within the map view to be exposed as well.
5480
+ This allows an application fine-grained control of the level of detail of interactions it responds to,
5481
+ from simple updates when the map is moved or the zoom level is changed,
5482
+ to detailed feedback during user interactions of longer duration such as continuous panning.
5483
+ </ p >
5439
5484
< p >
5440
- Author scripts may wish to be notified of map events. TODO
5485
+ In addition to events relating to the state of the map view itself,
5486
+ developers will expect to be able to receive notifications of events triggered by other components within the map
5487
+ such as controls, markers, and layers.
5488
+ </ p >
5489
+ < p >
5490
+ A native HTML map element would be expected to support the existing DOM event binding interface,
5491
+ using the standard < code > addEventListener()</ code > method to bind listener functions to map events,
5492
+ and receiving an object derived from the standard < code > Event</ code > interface
5493
+ as the argument to such functions.
5441
5494
</ p >
5442
5495
< p class ="issue discussion " data-number ="69 "> Discuss this section on GitHub.</ p >
5443
5496
5444
5497
< h5 > Existing implementations</ h5 >
5445
5498
< p >
5446
- Existing implementation support:
5499
+ Implementations of map events vary widely in both the terminology used and the semantic richness of the events available.
5500
+ For example, the Google Maps API provides events named < code > center_changed</ code >
5501
+ and < code > zoom_changed</ code > , allowing a developer to provide discrete event handlers for such changes.
5502
+ The Leaflet API supports similar events, but named < code > moveend</ code > and < code > zoomend</ code > .
5503
+ The Bing Maps API, on the other hand, provides a more general < code > viewchangeend</ code > event,
5504
+ and the handler for this event must examine the state of the map to determine what has changed.
5505
+ </ p >
5506
+ < p >
5507
+ APIs generally also provide lower level events directly correlating to user interactions,
5508
+ such as < code > click</ code > and < code > mouseover</ code > in the Google Maps API, though again terminology varies.
5509
+ The event objects passed to handlers of such events have additional properties compared to their equivalents
5510
+ in normal DOM event handling, such as a property giving the position of the event in terms of latitude and longitude.
5447
5511
</ p >
5448
5512
< dl data-ucr-role ="implementation-notes ">
5449
5513
<!-- Use dt elements to name the implementation, using the id string to create an auto-link.
@@ -5458,9 +5522,16 @@ <h5>Existing implementations</h5>
5458
5522
< dt > mapbox-gl-api</ dt >
5459
5523
< dt > leaflet-api</ dt >
5460
5524
< dt > open-layers-api</ dt >
5525
+ < dt > tomtom</ dt >
5461
5526
< dt > d3-geographies-api</ dt >
5462
- < dd > < a > not applicable </ a > :
5527
+ < dd > < a > supported, with limitations </ a > :
5463
5528
<!-- details about what is/isn't supported -->
5529
+ < p >
5530
+ Although all existing implementations support an events system capable of meeting the needs of developers,
5531
+ inconsistencies in terminology, semantic richness, and the interfaces provided for adding and removing
5532
+ event listeners mean that it is unclear whether any one of the existing APIs would be a suitable model
5533
+ for the various capabilities available across the entire range of them.
5534
+ </ p >
5464
5535
</ dd >
5465
5536
</ dl >
5466
5537
@@ -5469,13 +5540,24 @@ <h5>Supported use cases</h5>
5469
5540
5470
5541
< h5 > Uses beyond mapping</ h5 >
5471
5542
< p >
5472
- ToDo
5543
+ As it is anticipated that standard DOM event interfaces would be the basis for an HTML map's event system,
5544
+ it is likely that further uses could arise for such capabilities.
5545
+ For example, an HTML text annotated with geographical microdata could allow DOM events arising from user interaction
5546
+ (such as clicking on the name of a city within the text) to be enhanced with the same kind of position property,
5547
+ specifying latitude and longitude, as would be present in an event object created by a similar interaction
5548
+ with a map element.
5473
5549
</ p >
5474
5550
5475
5551
< h5 > Related web specifications</ h5 >
5476
5552
< p >
5477
5553
<!-- Any existing/proposed specs that address similar needs or otherwise interact.
5478
5554
Include links with proper ReSpec references. -->
5555
+ As outlined above, it is expected that events as defined in [[[DOM]]] would form the basis for a map element's
5556
+ event system.
5557
+ </ p >
5558
+ < p >
5559
+ [[[HTML]]] media objects provide an existing example of extending the basic event system to support
5560
+ particular capabilities of embedded content.
5479
5561
</ p >
5480
5562
5481
5563
< h5 > Conclusion</ h5 >
@@ -5485,13 +5567,43 @@ <h5>Conclusion</h5>
5485
5567
See examples.
5486
5568
-->
5487
5569
< p >
5488
- Based on the limited data, we are < a data-ucr-role ="conclusion "> undecided</ a > about whether this should be a requirement.
5570
+ This capability is a < a data-ucr-role ="conclusion "> requirement</ a > for the scripting API of a native HTML map element.
5571
+ Responding to changes in the state of a map, or user interactions with elements of the map such as markers,
5572
+ is necessary for a web application to usefully modify its own state so as to reflect the results of such interactions.
5489
5573
</ p >
5490
5574
< ul data-ucr-role ="conclusion-notes ">
5491
5575
<!-- bullet-point notes summarizing implementation details / blocking issues.
5492
5576
Add tags to the start of a point with an empty `<a data-ucr-role="tag"></a>` where the text content or href matches a tag `id` value. -->
5493
- < li > < a data-ucr-role ="tag " href =""> </ a >
5494
- <!-- short summary of how the tag applies -->
5577
+ < li > < a data-ucr-role ="tag " href =""> privacy-sensitive-data-revealed</ a >
5578
+ Collating the positions on which a user centres the map could allow a script to infer an interest
5579
+ in a particular region and, for example, target advertising accordingly.
5580
+ </ li >
5581
+ < li > < a data-ucr-role ="tag " href =""> accessibility-potential</ a >
5582
+ If events from maps and map interface elements are exposed to assistive technologies via the browser's
5583
+ existing accessibility mechanisms, it would be easier for those technologies to present them in a way
5584
+ consistent with other browser interactions.
5585
+ </ li >
5586
+ < li > < a data-ucr-role ="tag " href =""> performance-potential</ a >
5587
+ Existing implementations must perform complex tasks such as transforming browser coordinates to map coordinates
5588
+ in order to provide such data in enhanced event objects.
5589
+ Native implementations could be expected to provide significantly better performance.
5590
+ </ li >
5591
+ < li > < a data-ucr-role ="tag " href =""> author-extensibility</ a >
5592
+ The ability to respond to user interaction is crucial in building rich application interfaces that include embedded maps.
5593
+ </ li >
5594
+ < li > < a data-ucr-role ="tag " href =""> author-cost-cutting</ a >
5595
+ A standardised interface against which to write event-driven mapping applications reduces the amount of time developers
5596
+ need to spend becoming competent and productive.
5597
+ </ li >
5598
+ < li > < a data-ucr-role ="tag " href =""> consistency-match</ a >
5599
+ Current implementations already seek to either extend or mimic the existing event mechanism.
5600
+ </ li >
5601
+ < li > < a data-ucr-role ="tag " href =""> consistency-progressive</ a >
5602
+ An application can determine which event-driven enhancements it is capable of supporting in a given environment.
5603
+ </ li >
5604
+ < li > < a data-ucr-role ="tag " href =""> consistency-fallbacks</ a >
5605
+ An application can choose not to subscribe to a given event or events if it determines that it cannot usefully
5606
+ provide an enhancement in its current environment.
5495
5607
</ li >
5496
5608
</ ul >
5497
5609
</ section >
0 commit comments