On Oct 17, 9:56 pm, Kyle Pena <kp1...@gmail.com> wrote:
> Hi folks - my end game is calling the function
> fromContainerPixelToLatLng, but in order to get there, I need an
> instance of projection to play with.  But projection is undefined no
> matter how hard I try.
> Code:
>
>     function getGMap() {
>         var myLatlng = new google.maps.LatLng(...elided...);
>         var myOptions = {
>             zoom: 19,
>             center: myLatlng,
>             mapTypeId: google.maps.MapTypeId.SATELLITE,
>             draggable: true, /* You can move by dragging around */
>             scaleControl: false, /* But the control is not visible */
>             disableDefaultUI: true, /* Remove all the distracting
> google maps UI stuff */
>             disableDoubleClickZoom: true, /* And you can't double
> click to zoom */
>             scrollwheel: false /* And you can't scroll to zoom */
>         };
>         var map = new google.maps.Map($(".map")[0], myOptions);
>
>         // set up a prototype for google maps
>         MyOverlay.prototype = new google.maps.OverlayView();
>         MyOverlay.prototype.onAdd = function() { };
>         MyOverlay.prototype.onRemove = function() { };
>         MyOverlay.prototype.draw = function() { };
>         function MyOverlay(map) { this.setMap(map); };
>
>         // set up the GMap overlay (not the same as the HTML5 overlay
> I made)
>         // without setting up this overlay, google maps won't be able
> to get an instance of the projection, which we need for unit
> calculations
>         var overlay = new MyOverlay(map);
>         var projection = overlay.getProjection();
>         MyApp.Projection = projection;
>         return map;
>     };
>
> What's wrong?

As a guess (since you didn't provide a link to your map):
You need to wait for the projection_changed event to fire, indicating
the projection has been configured.

  -- Larry

-- 
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-maps-js-api...@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to