--- a/betweenpoint.php +++ b/betweenpoint.php @@ -7,71 +7,123 @@ function init() { - // create the ol map object - var map = new OpenLayers.Map('map'); + // create the ol map object + var map = new OpenLayers.Map('map'); - var osmtiles = new OpenLayers.Layer.OSM("local", "http://127.0.0.1/Maps/OSM/${z}/${x}/${y}.png") + var osmtiles = new OpenLayers.Layer.OSM("local", "/tiles/${z}/${x}/${y}.png") // use http://open.atlas.free.fr/GMapsTransparenciesImgOver.php and http://code.google.com/p/googletilecutter/ to make tiles - markers = new OpenLayers.Layer.Markers("Between Stop Markers"); - - + markers = new OpenLayers.Layer.Markers("Between Stop Markers"); + + //hanlde mousedown on regions that are not points by reporting latlng +OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { + defaultHandlerOptions: { + 'single': true, + 'double': false, + 'pixelTolerance': 0, + 'stopSingle': false, + 'stopDouble': false + }, + + initialize: function(options) { + this.handlerOptions = OpenLayers.Util.extend( + {}, this.defaultHandlerOptions + ); + OpenLayers.Control.prototype.initialize.apply( + this, arguments + ); + this.handler = new OpenLayers.Handler.Click( + this, { + 'click': this.trigger + }, this.handlerOptions + ); + }, + + trigger: function(e) { + var lonlat = map.getLonLatFromViewPortPx(e.xy).transform( + new OpenLayers.Projection("EPSG:900913"), + new OpenLayers.Projection("EPSG:4326") + ); + $('form input[name="newlatlng"]').val(lonlat.lat + ";" + lonlat.lon ); + } + + }); + var click = new OpenLayers.Control.Click(); + map.addControl(click); + click.activate(); -var timeicon = new OpenLayers.Icon("http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png",new OpenLayers.Size(32,32)); +var timeicon = new OpenLayers.Icon("icong.png",new OpenLayers.Size(16,16)); var timepoints = new OpenLayers.Layer.GeoRSS("Timing Points", "displaytimepoints.georss.php", { icon: timeicon }); map.addLayers([osmtiles, markers,timepoints]); map.addControl(new OpenLayers.Control.LayerSwitcher()); - map.zoomToExtent(markers.getDataExtent()); + map.zoomToExtent(markers.getDataExtent()); } - - function submit(){ - $.ajax({ - type: "POST", - url: "betweenpoint.submit.php", - data: "reverse=" + document.getElementById("reverse").value + - "&from=" + document.getElementById("from").value + - "&to=" + document.getElementById("to").value + - "&routes=" + document.getElementById("routes").value + - "&between_points=" + document.getElementById("between_points").value, - success: function(html){ - $("#response").html(html); - clearForms(); - } - }); - - } - // function will clear input elements on each form function clearForms(){ @@ -96,7 +148,7 @@ break; case "radio": case "checkbox": - document.forms[x].elements[y].checked = ""; + document.forms[x].elements[y].checked = true; break; case "select-one": document.forms[x].elements[y].options[0].selected = true; @@ -118,72 +170,85 @@ $processed"; ?> - - from - to + from + to
- on routes -Reverse? - + on routes +Reverse? +
- + -
- -
+
+oldgeopo +newlatlng + + + +
+
+ +
-