[OpenLayers-Users] Aspect Ratio/Projection Problem
Michael Langford
michael.langford at rowdylabs.com
Fri Jun 6 12:31:21 EDT 2008
This worked perfectly. Thank you so very much.
--Michael
On Fri, Jun 6, 2008 at 11:22 AM, Paul Spencer <pagameba at gmail.com> wrote:
> functional code attached. The problem is that you are mixing coordinate
> systems and while Google automatically assumes you are using lon/lat and
> transforms them internally, OpenLayers doesn't.
>
>
>
>
>
> Cheers
>
> Paul
>
> On 6-Jun-08, at 10:57 AM, Michael Langford wrote:
>
>> The options at that time was just {} now it as this.
>>
>> Now it is as the following, still behaves the same....
>>
>> var options = {
>> 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.34)
>> };
>>
>> g_map = new OpenLayers.Map('map', options);
>>
>> var mapbounds = new OpenLayers.Bounds(-74.766667,
>> 39.166666667,
>> -71.88333,
>> 40.88333)
>> var graphic = new OpenLayers.Layer.Image(
>> 'Oceantemp.com Temperatures',
>>
>> 'http://www.rowdylabs.com/gmaps/oceantemp/area-ne06.gif',
>> mapbounds,
>> new OpenLayers.Size(1030,796),
>> {maxExtext:mapbounds});
>>
>> g_map.addLayers([graphic]);
>> g_map.setCenter(new OpenLayers.LonLat(-73,40), -1);
>>
>> g_markers = new OpenLayers.Layer.Markers( "Markers" );
>> g_map.addLayer(g_markers)
>>
>> On Fri, Jun 6, 2008 at 8:09 AM, Paul Spencer <pagameba at gmail.com> wrote:
>>>
>>> Michael,
>>>
>>> I tried your code, you have omitted a critical piece which is the options
>>> object you are passing to the map constructor - please send so I can see
>>> what is going on.
>>>
>>> Cheers
>>>
>>> Paul
>>>
>>> On 6-Jun-08, at 3:33 AM, Michael Langford wrote:
>>>
>>>> I tried Paul's suggestion and it didn't change anything.
>>>>
>>>> I'll try to clarify and add code.
>>>>
>>>> If you take OpenLayers out of the picture entirely, and you use GMaps
>>>> instead to do what we're trying to do, you'd use a GGroundOverlay on
>>>> google maps to plop say a custom map of New York City down on top
>>>> (completely obscuring their map). When you do this, the google does
>>>> not in any way stretch, modify, reproject, etc, the images we are
>>>> using. It might with other images, but ours come out the same as they
>>>> go in, probably indicating we have the same projection as Google Maps,
>>>> or at least close enough these areas overlay correctly. Here is an
>>>> example of using GGroundOverlay:
>>>> http://www.usnaviguide.com/ws-2008-02/ggroundoverlay_example.htm
>>>> Notice his picture *IS* reprojected to fit on the google map (ours is
>>>> not).
>>>>
>>>> If we port our GGroundOverlay example from GMaps to open layers, we
>>>> throw down our custom map of say New York, then OpenLayers decides (at
>>>> least in the default setup), that it would like to stretch our custom
>>>> map overlay. Sure, it reports the correct lats and longs after doing
>>>> so, but it looks horrible, as there is lots of lettering and symbols
>>>> on the map which are stretched to near illegibility. We want to mimic
>>>> the projection that the screen map is in on Google Maps so as to avoid
>>>> any distortion.
>>>>
>>>> When we use an OpenLayer.Layer.Image on top of the default map that
>>>> you get when you go new OpenLayers.Map("map"), the picture is
>>>> distorted as OpenLayers reprojects the image or something like that,
>>>> elongating it in the east west direction.
>>>>
>>>> How can I use an image layer in OpenLayers to achieve the same
>>>> appearance as a GGroundOverlay in google maps, with no squishing and
>>>> stretching of the image overlay?
>>>>
>>>> As a further modification, we're actually just using the image as the
>>>> base map. We're not using a google map, WMS server or anything like
>>>> that, nor are we tiling our image. We're justing using the single
>>>> image that we were overlaying now as the "base layer" of the map.
>>>> We're just interested in the controls, markers, and nice map
>>>> pixel->coordinate translations, as well as your wonderful vector
>>>> drawing api.
>>>>
>>>> Remember when I say terms like "base layer" etc, I probably don't have
>>>> the same OpenLayers concepts you do, and I just mean its the map on
>>>> the bottom, we're not putting any pictures under it. Sorry if I used
>>>> terms different than they are in the Open Layers community.
>>>>
>>>> --Michael
>>>>
>>>> Here is the code that initializes the map:
>>>> var mapbounds = new OpenLayers.Bounds(-74.766667,
>>>> 39.166666667,
>>>> -71.88333,
>>>> 40.88333);
>>>>
>>>> g_map = new OpenLayers.Map('map', options);
>>>>
>>>> var graphic = new OpenLayers.Layer.Image(
>>>> 'Overlay of Temperature Data',
>>>>
>>>> 'http://www.rowdylabs.com/gmaps/oceantemp/area-ne06.gif',
>>>> mapbounds,
>>>> new OpenLayers.Size(1030,796),
>>>> {maxExtext:mapbounds});
>>>>
>>>> g_map.addLayers([graphic]);
>>>> g_map.setCenter(new OpenLayers.LonLat(-73,40), -1);
>>>>
>>>> g_markers = new OpenLayers.Layer.Markers( "Markers" );
>>>> g_map.addLayer(g_markers);
>>>>
>>>>
>>>> On Fri, Jun 6, 2008 at 2:22 AM, Eric Lemoine <eric.c2c at gmail.com> wrote:
>>>>>
>>>>> On Fri, Jun 6, 2008 at 12:43 AM, Michael Langford
>>>>> <michael.langford at rowdylabs.com> wrote:
>>>>>>
>>>>>> After switching to openlayers.org from google maps, we're almost ready
>>>>>> to launch my customer's new site.
>>>>>>
>>>>>> One problem though: His overlay image is "squished" on OpenLayers,
>>>>>> where it looks great using the image overlay of Google Maps API. It
>>>>>> involves way too many hours of hand lettered text on it to contemplate
>>>>>> redoing in the new aspect ratio, so I need to find a technical
>>>>>> solution to make OpenLayers.org display it properly.
>>>>>>
>>>>>> I've been fiddling with projections, and have not seen a way out of
>>>>>> this forest, as nothing appears to change the display of the image.
>>>>>>
>>>>>> When I look, I keep finding pointers on the web to the extremely brief
>>>>>> comment about projections on the FAQ, which doesn't help me at all.
>>>>>>
>>>>>> It seems like I'd like to display in EPSG:900313 as that is what
>>>>>> Google uses (that may not be the exact name, I deleted it after it
>>>>>> seemed clear it wasn't working).
>>>>>>
>>>>>> I'm not exactly sure the role the proj4js plays in this, but it seems
>>>>>> like it probably does.
>>>>>>
>>>>>> I've attached the picture of what the overlay looks like when applied
>>>>>> to google's map, and what the overlay looks like when applied to open
>>>>>> layers. In addition, it is available at
>>>>>> http://rowdylabs.com/ng/RightAndWrong.GIF in case the mailing list
>>>>>> doesn't like attachments.
>>>>>>
>>>>>> Hopefully someone can provide something like the following:
>>>>>>
>>>>>> You properly include proj4js at the top of your html file like so,
>>>>>> and you create your map with arguments like so.
>>>>>
>>>>> Hello
>>>>>
>>>>> I'm not sure I understand your problem. But if what you want is have
>>>>> overlays over google maps you'll need to use SphericalMercator. See
>>>>> some doc here <http://trac.openlayers.org/wiki/SphericalMercator> and
>>>>> some example there
>>>>> <http://www.openlayers.org/dev/examples/spherical-mercator.html>. Hope
>>>>> this will help you do what you want.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> --
>>>>> Eric
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Michael Langford
>>>> Phone: 404-386-0495
>>>> Web: http://www.RowdyLabs.com
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at openlayers.org
>>>> http://openlayers.org/mailman/listinfo/users
>>>
>>>
>>
>>
>>
>> --
>> Michael Langford
>> Phone: 404-386-0495
>> Web: http://www.RowdyLabs.com
>
>
>
--
Michael Langford
Phone: 404-386-0495
Web: http://www.RowdyLabs.com
More information about the Users
mailing list