UTM in v3

2333 views
Skip to first unread message

jbogdani

unread,
Feb 13, 2010, 6:50:28 PM2/13/10
to Google Maps JavaScript API v3
My answer is: Is there any way to work in UTM coordinates in gmaps v3?
I need to display some GIS data (shapefiles transformed in MySQL
spatial tables) in GMaps, and make them available in read/edit mode,
without loosing the possibility to view/edit in GIS environment (I'm
using QGIS).
All data are in projected mode (UTM) and I was wandering if is there
(o will be in future) a direct way to create markers (etc.) with
projected coordinates.

Ben Appleton

unread,
Feb 13, 2010, 7:00:14 PM2/13/10
to google-map...@googlegroups.com
Yes, you can implement a custom MapType
(http://code.google.com/apis/maps/documentation/v3/reference.html#MapType)
with custom Projection that implements your UTM. Then all overlays
(markers, polylines, etc.) will use UTM.

> --
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

bratliff

unread,
Feb 15, 2010, 11:51:30 AM2/15/10
to Google Maps JavaScript API v3

On Feb 14, 12:00 am, Ben Appleton <apple...@google.com> wrote:
> Yes, you can implement a custom MapType
> (http://code.google.com/apis/maps/documentation/v3/reference.html#MapType)
> with custom Projection that implements your UTM. Then all overlays
> (markers, polylines, etc.) will use UTM.

A simple documentation example (Euclidian Projection) might be
useful. UTM is not trivial. Both Easting & Northing depend on both
Latitude & Longitude. Zone depends on Longitude.

Josh Rosenthal

unread,
Feb 15, 2010, 2:57:29 PM2/15/10
to google-map...@googlegroups.com
Its not direct, but you might look at using proj4js to just convert
everything back and forth on the fly.
http://proj4js.org/
Depending on what you're after, performance may be a problem, but its
certainly worth a glance.

Philip

unread,
Feb 18, 2010, 10:27:17 PM2/18/10
to Google Maps JavaScript API v3
This is doable in V2 maps -- I have a projection that supports UTM for
the old maps. It seems that the projection support in V3 maps is not
yet baked. I don't see how to actually implement a projection with the
API that is specified -- in particular, there is no zoom parameter
passed to the projection. Calculating pixel coordinates without
knowing the zoom is tough.

Sorry

Philip

Ben Appleton

unread,
Feb 19, 2010, 1:30:16 AM2/19/10
to google-map...@googlegroups.com

In v3 the API handles zooming.

On 19 Feb 2010 14:30, "Philip" <philip...@gladstonefamily.net> wrote:

This is doable in V2 maps -- I have a projection that supports UTM for
the old maps. It seems that the projection support in V3 maps is not
yet baked. I don't see how to actually implement a projection with the
API that is specified -- in particular, there is no zoom parameter
passed to the projection. Calculating pixel coordinates without
knowing the zoom is tough.

Sorry

Philip


On Feb 13, 6:50 pm, jbogdani <jbogd...@gmail.com> wrote:

> My answer is: Is there any way to work i...

Philip

unread,
Feb 19, 2010, 9:17:53 AM2/19/10
to Google Maps JavaScript API v3
I don't understand this. The documentation for the various methods on
the MapCanvasProjection object do not reference 'zoom' at all. [This
is unlike V2 where the zoom is passed into the various conversion
methods]. It could be that there is a Projection object (and, indeed,
'Projection' is the type of the projection property on a MapType), but
I assumed that this was a mistype for MapCanvasProjection as there is
no Projection object documented.

The only reference to zoom in MapCanvasProjection is:

getWorldWidth() number The width of the world in pixels in the
current zoom level.

If I am implementing a MapCanvasProjection, then how do I discover the
current zoom level? [Bear in mind you can have multiple maps on the
same page, each with different zoom levels, and no way to reach any
map object from the MapCanvasProjection object]

I suspect that each of the methods is missing a zoom parameter. You
certainly wouldn't want to make the current zoom a property of the
projection.

Philip

On Feb 19, 1:30 am, Ben Appleton <apple...@google.com> wrote:
> In v3 the API handles zooming.
>

Marcelo

unread,
Feb 19, 2010, 10:46:27 AM2/19/10
to Google Maps JavaScript API v3
On Feb 19, 4:27 am, Philip <philip-goo...@gladstonefamily.net> wrote:
> Calculating pixel coordinates without
> knowing the zoom is tough.


Not really.
I already pointed you to documentation that demonstrates how to do it,
but I believe that you chose to ignore my advice when you said "I
understand how projections work".
Just to be on the safe side, I tried what I suggested in the other
thread, and I can get pixel coordinates in 3 lines of code.
You need to un-learn what you know from V2 here.

BTW, I might have clicked "reply to author" by mistake in a previous
attempt to post this message, and if I did I'm sorry about that.

--
Marcelo - http://maps.forum.nu
--

Message has been deleted

Philip

unread,
Feb 19, 2010, 12:03:38 PM2/19/10
to Google Maps JavaScript API v3
I agree that I can (too) get pixel coordinates by scaling the pixel
coordinates by 2**zoom. However, that isn't what the documentation
tells you to do. The example does that. I admit, but I also think that
the example is wrong for other reasons.

From the example at http://code.google.com/apis/maps/documentation/v3/examples/map-coordinates.html

MercatorProjection.prototype.fromPointToLatLng = function(point) {
//stuff not referencing 'point' but referencing 'pixel'. This is a
pure typo I think
}

The definition of a MapCanvasProjection object does not include this
method, but assuming that it really is (another typo for)
'fromDivPixelToLatLng', lets see what the documentation says about
this method: "Computes the geographical coordinates from pixel
coordinates in the div that holds the draggable map." (http://
code.google.com/apis/maps/documentation/v3/
reference.html#MapCanvasProjection )

Now -- what are the 'pixel coordinates'? I assumed (and this may be a
bad assumption) that the units are in pixels. Now, I will admit that
the documentation does not define 'pixel coordinates', but I think
that most people would assume that this was 'the coordinates in
pixels'.

If we could find an instance of a MapCanvasProjection object from one
of the google defined map types, then we could solve this issue pretty
easily (by looking at the methods and parameters of those methods).

Philip


On Feb 19, 10:46 am, Marcelo <marcelo...@hotmail.com> wrote:
> On Feb 19, 4:27 am, Philip <philip-goo...@gladstonefamily.net> wrote:
>
> > Calculating pixel coordinates without
> > knowing the zoom is tough.
>
> Not really.
> I already pointed you to documentation that demonstrates how to do it,
> but I believe that you chose to ignore my advice when you said "I
> understand how projections work".
> Just to be on the safe side, I tried what I suggested in the other
> thread, and I can get pixel coordinates in 3 lines of code.
> You need to un-learn what you know from V2 here.
>
> BTW, I might have clicked "reply to author" by mistake in a previous
> attempt to post this message, and if I did I'm sorry about that.
>
> --

> Marcelo -http://maps.forum.nu

Chad Killingsworth

unread,
Feb 19, 2010, 5:25:08 PM2/19/10
to Google Maps JavaScript API v3
The MapCanvasProjection here:
http://code.google.com/apis/maps/documentation/v3/reference.html#MapCanvasProjection
is obtainable only through extending OverlayView (as far as I have
found). It does not implement the Projection interface in the example
you have listed or discussed here:
http://code.google.com/apis/maps/documentation/v3/overlays.html#Projections
- As far as I can tell they are different objects. Yes this is very
confusing.

There was a discussion either in this group or in an issue in the
issue tracker about why the base projection was not available. It had
to do with not exposing objects that were loaded asynchronously if I
recall correctly.

Chad Killingsworth

On Feb 19, 11:03 am, Philip <philip-goo...@gladstonefamily.net> wrote:
> I agree that I can (too) get pixel coordinates by scaling the pixel
> coordinates by 2**zoom. However, that isn't what the documentation
> tells you to do. The example does that. I admit, but I also think that
> the example is wrong for other reasons.
>

> From the example athttp://code.google.com/apis/maps/documentation/v3/examples/map-coordi...

Ze 910

unread,
Jul 10, 2011, 6:13:48 AM7/10/11
to google-map...@googlegroups.com
Hello
I'm new to google map api and I also facing this problem (using utm). Datas extracted from my database are in UTM and I want them to appear on a map. 
Is there any simple to understand example with google map API in UTM ?

Thank you for your support.
Reply all
Reply to author
Forward
0 new messages