|
I am having a weird problem and have tried
almost everything to fix it. I am creating a bunch of GML files and pointing them at open layers to draw lines over a map. The lines are being drawn Ok but when you pan up, the location the lines are on the map does not move the same amount as the map. Also the lines at the top and bottom of the map do not follow the roads that the location references give (where as the ones in the middle do). This problem seems only to relate to the vertical axis, not the horizontal. I have stripped back the code to the most basic components and it has made no difference and am referencing the on line version of open layers. I have also added the google workaround. Any help appreciated. HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Map</title> <style type="text/css"> #map { width: 100%; height: 600px; border: 1px solid black; background-color: red; } </style> <script src="" moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAiL5fH4uW-yV8VTcbOVPBRhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSM77ok_15xYCWhpsc3DaKZB-rsUQ">"http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAiL5fH4uW-yV8VTcbOVPBRhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSM77ok_15xYCWhpsc3DaKZB-rsUQ"></script> <script src="" moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="http://www.openlayers.org/api/OpenLayers.js">"http://www.openlayers.org/api/OpenLayers.js"></script> <script type="text/_javascript_"> var lon = -1.467762; var lat = 53.383160; var zoom = 6; var map; function init(){ OpenLayers.Layer.Google.prototype.addContainerPxFunction=function() { if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) { GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) { // first we translate into "DivPixel" var gPoint = this.fromLatLngToDivPixel(gLatLng); // locate the sliding "Div" div var div = this.getContainer().firstChild.firstChild; // adjust by the offset of "Div" and voila! gPoint.x += div.offsetLeft; gPoint.y += div.offsetTop; return gPoint; }; } }; map = new OpenLayers.Map( 'map' , { controls: [new OpenLayers.Control.MouseDefaults()] , 'numZoomLevels':20}); map.addLayer(new OpenLayers.Layer.Google( "Google" )); var greenLayerGML = new OpenLayers.Layer.GML("Slight Disruption", "../../pages/map/layerGML.ashx?severity=slight"); greenLayerGML.preFeatureInsert = function(feature) { feature.style.strokeWidth="5"; feature.style.strokeColor="#CCFF66";}; map.addLayer(greenLayerGML); var amberLayerGML = new OpenLayers.Layer.GML("Moderate Disruption", "../../pages/map/layerGML.ashx?severity=moderate"); amberLayerGML.preFeatureInsert = function(feature) { feature.style.strokeWidth="5"; feature.style.strokeColor="#FF9933";}; map.addLayer(amberLayerGML); var redLayerGML = new OpenLayers.Layer.GML("Severe Disruption", "../../pages/map/layerGML.ashx?severity=severe"); redLayerGML.preFeatureInsert = function(feature) { feature.style.strokeWidth="5"; feature.style.strokeColor="#FF3300";}; map.addLayer(redLayerGML); map.setCenter(new OpenLayers.LonLat(10.205188,48.857593), 5); map.addControl( new OpenLayers.Control.LayerSwitcher() ); map.addControl( new OpenLayers.Control.PanZoomBar() ); map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); } </script> </head> <body > <form id="form1" runat="server"> <div id="map"> </div> </form> </body> </html> -- Richard Thurbin www.cloudamber.com +44 7917 704 145 |
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
