Phew.... solved this one. It was user error (a faulty call in the html5
location sensing routine).
On Jan 6, 2012, at 11:13 AM, Puneet Kishor wrote:
> a little more investigation, more revelation (see below)
>
> On Jan 6, 2012, at 10:50 AM, Puneet Kishor wrote:
>
>> I am experiencing a strange behavior that perhaps someone can help me
>> troubleshoot. I am trying to make some custom mods to OpenLayers 2.11 --
>> nothing fancy, nothing in the JavaScript, only some of the buttons and
>> images. So, I made a copy of my OL installation, and called it
>> OpenLayers-copy, and replaced my OL script line in my web page like so
>>
>> - <script type="text/javascript"
>> src="path/to/lib/OpenLayers-2.11/OpenLayers.js"></script>
>> + <script type="text/javascript"
>> src="path/to/lib/OpenLayers-copy/OpenLayers.js"></script>
>>
>> var map = new OpenLayers.Map("map", {
>> "controls": [
>> - new OpenLayers.Control.LayerSwitcher(),
>> - new OpenLayers.Control.Navigation(),
>> - new OpenLayers.Control.PanZoom(),
>> + new OpenLayers.Control.LayerSwitcher({
>> + "roundedCornerColor": "rgba(0,0,0,0.8)"
>> + }),
>> + new OpenLayers.Control.ZoomPanel(),
>> new OpenLayers.Control.MousePosition({
>> "div": document.getElementById("coords"),
>> "numDigits": 2
>> })
>> ],
>> "projection": new OpenLayers.Projection("EPSG:900913"),
>> "displayProjection": new OpenLayers.Projection("EPSG:4326"),
>> "units": "m",
>> "maxResolution": 156543.0339,
>> "maxExtent": new OpenLayers.Bounds(-20037508, -20037508, 20037508,
>> 20037508)
>> });
>>
>> map.events.register("click", map, collections);
>>
>> "collections": function(e) {
>> var lonlat = map.getLonLatFromViewPortPx(e.xy).transform(
>> new OpenLayers.Projection("EPSG:900913"),
>> new OpenLayers.Projection("EPSG:4326")
>> );
>>
>> .. do something with lng/lat ..
>> }
>>
>>
>> That is the extent of my OL changes. I am now seeing the following two
>> behaviors that are foxing me --
>>
>> 1. The mouse display shows the correct mouse position in lng lat, however,
>> the actual point clicked on (for further querying is off by several tens of
>> degrees. For example, if I click at [-78.71, 43.33], the actual point
>> calculated by the click event listener is [-61.45, 61.61]. Why?
>>
>
> I changed the OL library to the original, as downloaded from OL servers. The
> click reported by the mouse position display is off from the click reported
> by the map listener even with the original OL library, albeit, by a smaller
> amount. For example, I clicked on [-78.35, 43.45] as shown in the mouse
> position display. The click event reported [-77.97, 49.61]. A very small lng
> shift but a fairly large lat shift.
>
> This is quite perplexing, and definitely very erroneous.
>
>> 2. I am unable to drag and pan the map. On the other hand, if I bring back
>> Control.Navigation and Control.PanZoom then I am able to drag pan the map. I
>> want to be able to drag pan the map, but I don't want to show the PanZoom
>> controls. How can I achieve that?
>>
>> Many thanks,
>>
>>
>> --
>> Puneet Kishor
>>
>>
>
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users