Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4547754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:08:05+00:00 2026-05-21T16:08:05+00:00

Recently I found out the hard way that to convert between LatLngs and pixel

  • 0

Recently I found out the hard way that to convert between LatLngs and pixel coordinates on screen I shouldn’t use the Projection class that is easily accessed through Map.getProjection, but instead I should use the MapCanvasProjection class that can only be accessed through OverlayView.

The latter is nice and handy if you are working with a custom overlay, but if you’re not, it’s really painful to get access to the MapCanvasProjection. So far I have solved this problem for myself by adding a method to the Map class that will give me easy access to the desired projection class:

google.maps.Map.prototype.getCanvasProjection = function() {
  if (!this.projectionOverlay) {
    this.projectionOverlay = new google.maps.OverlayView();
    this.projectionOverlay.onAdd = function(){};
    this.projectionOverlay.onRemove = function(){};
    this.projectionOverlay.draw = function(){};
    this.projectionOverlay.setMap(this);
  }
  return this.projectionOverlay.getProjection();
};

This all looks like a big hack to do something that should be trivial. And it ever more makes me wonder what does the google.maps.Projection class do? When I read the documentation it seems to me that Projection.fromLatLngToPoint does the same thing as MapCanvasProjection.fromLatLngToContainerPixel, but it does not. I’m puzzled.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:08:06+00:00Added an answer on May 21, 2026 at 4:08 pm

    Projection.fromLatLngToPoint means converting from Latitude Longitude to Mercator projection. MapCanvasProjection does a projection to pixel (including Mercator).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The obvious answer is to use Charset.defaultCharset() but we recently found out that this
I recently found out that I can use any dialect of Lisp for the
I recently found out that I need to use the cellspacing attribute in my
I have recently found out that there exists a method called nth_element in the
I have recently found out that no argument constructor and multiple argument constructor cannnot
Recently I found out that there are several things that one can do to
I found out recently that JList (finally!) was generified in JDK7. Why JTree and
I recently found out that the types of parameters in a non-defining function declaration
I recently found out that you can fake directory structure on S3 by putting
I recently found out that PHP 5.3 supports new language construct called GOTO .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.