Avoid a JS error on (e.g.) ?way=nnnnn

When showing an object, the map location is not set
until the vector layer has finished loading. Thus
map.getCenter() returns null.

Registering the events earlier avoids the need to call
updateLocation manually at all.
This commit is contained in:
John Firebaugh 2012-10-01 19:21:37 -07:00 committed by Tom Hughes
parent c6e267f2bd
commit f3afd43076

View file

@ -7,6 +7,9 @@ $(document).ready(function () {
var params = OSM.mapParams();
var map = createMap("map");
map.events.register("moveend", map, updateLocation);
map.events.register("changelayer", map, updateLocation);
if (!params.object_zoom) {
if (params.bbox) {
var bbox = new OpenLayers.Bounds(params.minlon, params.minlat, params.maxlon, params.maxlat);
@ -39,10 +42,6 @@ $(document).ready(function () {
$(window).load(function() { addObjectToMap(url, params.object_zoom) });
}
map.events.register("moveend", map, updateLocation);
map.events.register("changelayer", map, updateLocation);
updateLocation();
handleResize();
$("#show_data").click(function (e) {