@@ -5437,22 +5437,42 @@ <h5>Conclusion</h5>
5437
5437
< section id ="capability-map-events " data-ucr-role ="capability ">
5438
5438
< h4 > Subscribe to notifications of map events</ h4 >
5439
5439
< 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,
5442
5442
so that it can update its own internal state and user interface as necessary to remain consistent with the map view.
5443
5443
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.
5446
5445
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.
5450
5459
</ p >
5451
5460
< p class ="issue discussion " data-number ="69 "> Discuss this section on GitHub.</ p >
5452
5461
5453
5462
< h5 > Existing implementations</ h5 >
5454
5463
< 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.
5456
5476
</ p >
5457
5477
< dl data-ucr-role ="implementation-notes ">
5458
5478
<!-- Use dt elements to name the implementation, using the id string to create an auto-link.
@@ -5467,9 +5487,16 @@ <h5>Existing implementations</h5>
5467
5487
< dt > mapbox-gl-api</ dt >
5468
5488
< dt > leaflet-api</ dt >
5469
5489
< dt > open-layers-api</ dt >
5490
+ < dt > tomtom</ dt >
5470
5491
< dt > d3-geographies-api</ dt >
5471
- < dd > < a > not applicable </ a > :
5492
+ < dd > < a > supported, with limitations </ a > :
5472
5493
<!-- 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 >
5473
5500
</ dd >
5474
5501
</ dl >
5475
5502
@@ -5478,13 +5505,24 @@ <h5>Supported use cases</h5>
5478
5505
5479
5506
< h5 > Uses beyond mapping</ h5 >
5480
5507
< 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.
5482
5514
</ p >
5483
5515
5484
5516
< h5 > Related web specifications</ h5 >
5485
5517
< p >
5486
5518
<!-- Any existing/proposed specs that address similar needs or otherwise interact.
5487
5519
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.
5488
5526
</ p >
5489
5527
5490
5528
< h5 > Conclusion</ h5 >
@@ -5494,13 +5532,62 @@ <h5>Conclusion</h5>
5494
5532
See examples.
5495
5533
-->
5496
5534
< 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.
5498
5538
</ p >
5499
5539
< ul data-ucr-role ="conclusion-notes ">
5500
5540
<!-- bullet-point notes summarizing implementation details / blocking issues.
5501
5541
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.
5504
5591
</ li >
5505
5592
</ ul >
5506
5593
</ section >
0 commit comments