Skip to content

Commit 7552a01

Browse files
committed
Expanded events capability, addressing #69.
As mentioned in the issue, it is probably necessary to distinguish and expand upon different kinds of events (such as those from controls) in a separate capability or capabilities, but I think this gives us a starting point.
1 parent 9882818 commit 7552a01

File tree

1 file changed

+100
-13
lines changed

1 file changed

+100
-13
lines changed

index.html

Lines changed: 100 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5437,22 +5437,42 @@ <h5>Conclusion</h5>
54375437
<section id="capability-map-events" data-ucr-role="capability">
54385438
<h4>Subscribe to notifications of map events</h4>
54395439
<p>
5440-
A web application embedding a map will usually need to respond to changes in the state of the map as a result of
5441-
user activity or from other causes,
5440+
A web application embedding a map will commonly need to respond to changes in the state of the map,
5441+
whether as a result of user activity or from other causes,
54425442
so that it can update its own internal state and user interface as necessary to remain consistent with the map view.
54435443
At a minimum, any change of the area displayed by the map needs to be notified to the application.
5444-
In practice, it is usually desirable for the causes of changes to be distinguishable from each other,
5445-
and for other high-level events within the map view to be exposed.
5444+
In practice, it is usually desirable for other high-level events within the map view to be exposed as well.
54465445
This allows an application fine-grained control of the level of detail of interactions it responds to,
5447-
from a simple update when the map is moved or the zoom level is changed,
5448-
to detailed feedback presented in its user interface during user interactions of longer duration
5449-
such as continuous panning.
5446+
from simple updates when the map is moved or the zoom level is changed,
5447+
to detailed feedback during user interactions of longer duration such as continuous panning.
5448+
</p>
5449+
<p>
5450+
In addition to events relating to the state of the map view itself,
5451+
developers will expect to be able to receive notifications of events triggered by other components within the map
5452+
such as controls, markers, and layers.
5453+
</p>
5454+
<p>
5455+
A native HTML map element would be expected to support the existing DOM event binding interface,
5456+
using the standard <code>addEventListener()</code> method to bind listener functions to map events,
5457+
and receiving an object derived from the standard <code>Event</code> interface
5458+
as the argument to such functions.
54505459
</p>
54515460
<p class="issue discussion" data-number="69">Discuss this section on GitHub.</p>
54525461

54535462
<h5>Existing implementations</h5>
54545463
<p>
5455-
5464+
Implementations of map events vary widely in both the terminology used and the semantic richness of the events available.
5465+
For example, the Google Maps API provides events named <code>center_changed</code>
5466+
and <code>zoom_changed</code>, allowing a developer to provide discrete event handlers for such changes.
5467+
The Leaflet API supports similar events, but named <code>moveend</code> and <code>zoomend</code>.
5468+
The Bing Maps API, on the other hand, provides a more general <code>viewchangeend</code> event,
5469+
and the handler for this event must examine the state of the map to determine what has changed.
5470+
</p>
5471+
<p>
5472+
APIs generally also provide lower level events directly correlating to user interactions,
5473+
such as <code>click</code> and <code>mouseover</code> in the Google Maps API, though again terminology varies.
5474+
The event objects passed to handlers of such events have additional properties compared to their equivalents
5475+
in normal DOM event handling, such as a property giving the position of the event in terms of latitude and longitude.
54565476
</p>
54575477
<dl data-ucr-role="implementation-notes">
54585478
<!-- Use dt elements to name the implementation, using the id string to create an auto-link.
@@ -5467,9 +5487,16 @@ <h5>Existing implementations</h5>
54675487
<dt>mapbox-gl-api</dt>
54685488
<dt>leaflet-api</dt>
54695489
<dt>open-layers-api</dt>
5490+
<dt>tomtom</dt>
54705491
<dt>d3-geographies-api</dt>
5471-
<dd><a>not applicable</a>:
5492+
<dd><a>supported, with limitations</a>:
54725493
<!-- details about what is/isn't supported -->
5494+
<p>
5495+
Although all existing implementations support an events system capable of meeting the needs of developers,
5496+
inconsistencies in terminology, semantic richness, and the interfaces provided for adding and removing
5497+
event listeners mean that it is unclear whether any one of the existing APIs would be a suitable model
5498+
for the various capabilities available across the entire range of them.
5499+
</p>
54735500
</dd>
54745501
</dl>
54755502

@@ -5478,13 +5505,24 @@ <h5>Supported use cases</h5>
54785505

54795506
<h5>Uses beyond mapping</h5>
54805507
<p>
5481-
ToDo
5508+
As it is anticipated that standard DOM event interfaces would be the basis for an HTML map's event system,
5509+
it is likely that further uses could arise for such capabilities.
5510+
For example, an HTML text annotated with geographical microdata could allow DOM events arising from user interaction
5511+
(such as clicking on the name of a city within the text) to be enhanced with the same kind of position property,
5512+
specifying latitude and longitude, as would be present in an event object created by a similar interaction
5513+
with a map element.
54825514
</p>
54835515

54845516
<h5>Related web specifications</h5>
54855517
<p>
54865518
<!-- Any existing/proposed specs that address similar needs or otherwise interact.
54875519
Include links with proper ReSpec references. -->
5520+
As outlined above, it is expected that events as defined in [[[DOM]]] would form the basis for a map element's
5521+
event system.
5522+
</p>
5523+
<p>
5524+
[[[HTML]]] media objects provide an existing example of extending the basic event system to support
5525+
particular capabilities of embedded content.
54885526
</p>
54895527

54905528
<h5>Conclusion</h5>
@@ -5494,13 +5532,62 @@ <h5>Conclusion</h5>
54945532
See examples.
54955533
-->
54965534
<p>
5497-
Based on the limited data, we are <a data-ucr-role="conclusion">undecided</a> about whether this should be a requirement.
5535+
This capability is a <a data-ucr-role="conclusion">requirement</a> for the scripting API of a native HTML map element.
5536+
Responding to changes in the state of a map, or user interactions with elements of the map such as markers,
5537+
is necessary for a web application to usefully modify its own state so as to reflect the results of such interactions.
54985538
</p>
54995539
<ul data-ucr-role="conclusion-notes">
55005540
<!-- bullet-point notes summarizing implementation details / blocking issues.
55015541
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. -->
5502-
<li><a data-ucr-role="tag" href=""></a>
5503-
<!-- short summary of how the tag applies -->
5542+
<li><a data-ucr-role="tag">privacy-fingerprinting</a>
5543+
As scripts may be loaded from arbitrary origins (depending on cross-rigin restrictions),
5544+
an event object including information about a map might allow deductions to be made about a viewer's device.
5545+
For example, the bounds of a map in a responsive design could vary depending on the device on which it is viewed,
5546+
allowing a third-party script to determine that a user is on a handheld device such as a phone.
5547+
</li>
5548+
<li><a data-ucr-role="tag" href="">security-ui</a>
5549+
Use of the event system's <code>stopPropagation()</code> and <code>preventDefault()</code> methods
5550+
could allow a third-party script to prevent a user from viewing particular areas, or more generally
5551+
interfere with correct operation of the map's UI.
5552+
</li>
5553+
<li><a data-ucr-role="tag" href="">privacy-sensitive-data-revealed</a>
5554+
Collating the positions on which a user centres the map could allow a script to infer an interest
5555+
in a particular region and, for example, target advertising accordingly.
5556+
</li>
5557+
<li><a data-ucr-role="tag" href="">security-potential</a>
5558+
By appropriately restricting scripted access to event properties, a built-in browser map implementation
5559+
could prevent leakage to cross-origin scripts of the kind of information outlined in the above points,
5560+
in a way not achievable by existing implementations.
5561+
</li>
5562+
<li><a data-ucr-role="tag" href="">accessibility-potential</a>
5563+
If events from maps and map interface elements are exposed to assistive technologies via the browser's
5564+
existing accessibility mechanisms, it would be easier for those technologies to present them in a way
5565+
consistent with other browser interactions.
5566+
</li>
5567+
<li><a data-ucr-role="tag" href="">performance-potential</a>
5568+
Existing implementations must perform complex tasks such as transforming browser coordinates to map coordinates
5569+
in order to provide such data in enhanced event objects.
5570+
Native implementations could be expected to provide significantly better performance.
5571+
</li>
5572+
<li><a data-ucr-role="tag" href="">author-simplicity</a>
5573+
Consistency of the event interface with other HTML elements would simplify coding.
5574+
</li>
5575+
<li><a data-ucr-role="tag" href="">author-extensibility</a>
5576+
The abilty to respond to user interaction is crucial in building rich application interfaces that include embedded maps.
5577+
</li>
5578+
<li><a data-ucr-role="tag" href="">author-cost-cutting</a>
5579+
A standard interface against which to write event-driven mapping applications reduces the amount of time developers
5580+
need to spend becoming competent and productive.
5581+
</li>
5582+
<li><a data-ucr-role="tag" href="">consistency-match</a>
5583+
Current implementations already seek to either extend or mimic the existing event mechanism.
5584+
</li>
5585+
<li><a data-ucr-role="tag" href="">consistency-progressive</a>
5586+
An application can determine which event-driven enhancements it is capable of supporting in a given environment.
5587+
</li>
5588+
<li><a data-ucr-role="tag" href="">consistency-fallbacks</a>
5589+
An application can choose not to subscribe to a given event or events if it determines that it cannot usefully
5590+
provide an enhancement in its current environment.
55045591
</li>
55055592
</ul>
55065593
</section>

0 commit comments

Comments
 (0)