// This function might be passed either an OpenLayers.LonLat (so has // lon and lat) or an OpenLayers.Geometry.Point (so has x and y) function fixmystreet_update_pin(lonlat) { lonlat.transform( fixmystreet.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326") ); document.getElementById('fixmystreet.latitude').value = lonlat.lat || lonlat.y; document.getElementById('fixmystreet.longitude').value = lonlat.lon || lonlat.x; } function fixmystreet_activate_drag() { fixmystreet.drag = new OpenLayers.Control.DragFeature( fixmystreet.markers, { onComplete: function(feature, e) { fixmystreet_update_pin( feature.geometry.clone() ); } } ); fixmystreet.map.addControl( fixmystreet.drag ); fixmystreet.drag.activate(); } function fms_markers_list(pins, transform) { var markers = []; for (var i=0; iMore details", { size: new OpenLayers.Size(0,0), offset: new OpenLayers.Pixel(0,-40) }, true, onPopupClose); feature.popup = popup; fixmystreet.map.addPopup(popup); }); fixmystreet.map.addControl( select ); select.activate(); } else if (fixmystreet.page == 'new') { fixmystreet_activate_drag(); } fixmystreet.map.addLayer(fixmystreet.markers); if ( fixmystreet.zoomToBounds ) { var bounds = fixmystreet.markers.getDataExtent(); if (bounds) { fixmystreet.map.zoomToExtent( bounds ); } } $('#hide_pins_link').click(function(e) { e.preventDefault(); var showhide = [ 'Show pins', 'Hide pins', 'Dangos pinnau', 'Cuddio pinnau', "Vis nåler", "Gjem nåler" ]; for (var i=0; i 0 ) { $('#form_category').change( form_category_onchange ); } }); $('#side-form, #site-logo').show(); /* For some reason on IOS5 if you use the jQuery show method it * doesn't display the JS validation error messages unless you do this * or you cause a screen redraw by changing the phone orientation. * NB: This has to happen after the call to show() */ if ( navigator.userAgent.match(/like Mac OS X/i)) { document.getElementById('side-form').style.display = 'block'; } $('#side').hide(); heightFix('#report-a-problem-sidebar:visible', '.content', 26); // If we clicked the map somewhere inconvenient var sidebar = $('#report-a-problem-sidebar'); if (sidebar.css('position') == 'absolute') { var w = sidebar.width(), h = sidebar.height(), o = sidebar.offset(); if (e.xy.y <= o.top) { // top of the page, pin hidden by header lonlat.transform( new OpenLayers.Projection("EPSG:4326"), fixmystreet.map.getProjectionObject() ); var p = fixmystreet.map.getViewPortPxFromLonLat(lonlat); p.x -= $(window).width() / 3; lonlat = fixmystreet.map.getLonLatFromViewPortPx(p); fixmystreet.map.panTo(lonlat); } else if (e.xy.x >= o.left && e.xy.x <= o.left + w + 24 && e.xy.y >= o.top && e.xy.y <= o.top + h + 64) { // underneath where the new sidebar will appear fixmystreet.map.pan(-w, 0, { animate: true }); } } if ($('html').hasClass('mobile')) { $('#sub_map_links').hide(); $('#map_box').append( '' ); $('.mobile-map-banner').text('Right place?'); // mobile user clicks 'ok' on map $('#mob_ok').on('click', function(e){ e.preventDefault(); //scroll the height of the map box instead of the offset //of the #side-form or whatever as we will probably want //to do this on other pages where #side-form might not be var height = $('#map_box').height(); $('html, body').animate({scrollTop:height}, 1000); }); } fixmystreet.page = 'new'; location.hash = 'report'; } });