mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
7
API.md
7
API.md
@@ -8,8 +8,8 @@ iD supports several URL parameters. When constructing a URL to a standalone inst
|
||||
of iD (e.g. `http://openstreetmap.us/iD/release/`), the following parameters are available
|
||||
in the hash portion of the URL:
|
||||
|
||||
* `map` - A slash separated `zoom/longitude/latitude`. Example:
|
||||
`map=20.00/-77.02271/38.90085`
|
||||
* `map` - A slash separated `zoom/latitude/longitude`. Example:
|
||||
`map=20.00/38.90085/-77.02271`
|
||||
* `id` - The character 'n', 'w', or 'r', followed by the OSM ID of a node,
|
||||
way or relation, respectively. Selects the specified entity, and, unless
|
||||
a `map` parameter is also provided, centers the map on it.
|
||||
@@ -35,8 +35,7 @@ When constructing a URL to an instance of iD embedded in the OpenStreetMap Rails
|
||||
Port (e.g. `http://www.openstreetmap.org/edit?editor=id`), the following parameters
|
||||
are available as regular URL query parameters:
|
||||
|
||||
* `map` - slash separated `zoom/latitude/longitude`. Example:
|
||||
`map=20.00/38.90085/-77.02271`.
|
||||
* `map` - same as standalone
|
||||
* `lat`, `lon`, `zoom` - Self-explanatory.
|
||||
* `node`, `way`, `relation` - Select the specified entity.
|
||||
* `background` - same as standalone
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* :warning: iD now uses `npm` scripts for all build processes
|
||||
* iD requires Node v4 or higher, but does not require `make` anymore
|
||||
* Update install instructions and prerequisites (#3466, thanks @tyrasd)
|
||||
* :warning: iD url hash map order has changed to `zoom/latitude/longitude` to match OSM and others (#3554)
|
||||
* Many preset improvements:
|
||||
* Add Construction and Tower Type fields to Mast and Tower presets (#3561, thanks @bkil)
|
||||
* Add Turning Loop (Island) preset, adjust icons for traversable/nontraversable features (#3557)
|
||||
|
||||
@@ -14,8 +14,8 @@ export function behaviorHash(context) {
|
||||
if (args.length < 3 || args.some(isNaN)) {
|
||||
return true; // replace bogus hash
|
||||
} else if (s !== formatter(map).slice(1)) {
|
||||
map.centerZoom([args[1],
|
||||
Math.min(lat, Math.max(-lat, args[2]))], args[0]);
|
||||
map.centerZoom([args[2],
|
||||
Math.min(lat, Math.max(-lat, args[1]))], args[0]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,8 +40,8 @@ export function behaviorHash(context) {
|
||||
}
|
||||
|
||||
newParams.map = zoom.toFixed(2) +
|
||||
'/' + center[0].toFixed(precision) +
|
||||
'/' + center[1].toFixed(precision);
|
||||
'/' + center[1].toFixed(precision) +
|
||||
'/' + center[0].toFixed(precision);
|
||||
|
||||
return '#' + utilQsString(_.assign(q, newParams), true);
|
||||
};
|
||||
|
||||
@@ -4,15 +4,13 @@ describe('iD.behaviorHash', function () {
|
||||
var hash, context;
|
||||
|
||||
beforeEach(function () {
|
||||
context = iD.Context(window)
|
||||
.imagery(iD.dataImagery);
|
||||
context = iD.Context(window);
|
||||
context.container(d3.select(document.createElement('div')));
|
||||
|
||||
// Neuter connection
|
||||
context.connection().loadTiles = function () {};
|
||||
|
||||
hash = iD.behaviorHash(context);
|
||||
|
||||
d3.select(document.createElement('div'))
|
||||
.call(context.map());
|
||||
});
|
||||
@@ -22,18 +20,14 @@ describe('iD.behaviorHash', function () {
|
||||
});
|
||||
|
||||
it('sets hadHash if location.hash is present', function () {
|
||||
location.hash = 'map=20.00/-77.02405/38.87952';
|
||||
|
||||
location.hash = 'map=20.00/38.87952/-77.02405';
|
||||
hash();
|
||||
|
||||
expect(hash.hadHash).to.be.true;
|
||||
});
|
||||
|
||||
it('centerZooms map to requested level', function () {
|
||||
location.hash = 'map=20.00/-77.02405/38.87952';
|
||||
|
||||
location.hash = 'map=20.00/38.87952/-77.02405';
|
||||
hash();
|
||||
|
||||
expect(context.map().center()[0]).to.be.closeTo(-77.02405, 0.1);
|
||||
expect(context.map().center()[1]).to.be.closeTo(38.87952, 0.1);
|
||||
expect(context.map().zoom()).to.equal(20.0);
|
||||
@@ -41,7 +35,6 @@ describe('iD.behaviorHash', function () {
|
||||
|
||||
it('centerZooms map at requested coordinates on hash change', function (done) {
|
||||
hash();
|
||||
|
||||
d3.select(window).on('hashchange', function () {
|
||||
expect(context.map().center()[0]).to.be.closeTo(-77.02405, 0.1);
|
||||
expect(context.map().center()[1]).to.be.closeTo(38.87952, 0.1);
|
||||
@@ -49,24 +42,17 @@ describe('iD.behaviorHash', function () {
|
||||
d3.select(window).on('hashchange', null);
|
||||
done();
|
||||
});
|
||||
|
||||
location.hash = 'map=20.00/-77.02405/38.87952';
|
||||
location.hash = 'map=20.00/38.87952/-77.02405';
|
||||
});
|
||||
|
||||
it('stores the current zoom and coordinates in location.hash on map move events', function () {
|
||||
location.hash = '';
|
||||
|
||||
hash();
|
||||
|
||||
var clock = sinon.useFakeTimers();
|
||||
|
||||
context.map().center([38.9, -77.0]);
|
||||
context.map().center([-77.0, 38.9]);
|
||||
context.map().zoom(2.0);
|
||||
|
||||
clock.tick(500);
|
||||
|
||||
expect(location.hash).to.equal('#map=2.00/38.9/-77.0');
|
||||
|
||||
clock.restore();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user