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

  • Home
  • SEARCH
  • 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 842509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:58:29+00:00 2026-05-15T05:58:29+00:00

I need to update this code: radar_layer.getTileUrl=function(tile,zoom) { var llp = new GPoint(tile.x*256,(tile.y+1)*256); var

  • 0

I need to update this code:

radar_layer.getTileUrl=function(tile,zoom) {

    var llp = new GPoint(tile.x*256,(tile.y+1)*256);
    var urp = new GPoint((tile.x+1)*256,tile.y*256);
    var ll = G_NORMAL_MAP.getProjection().fromPixelToLatLng(llp,zoom);
    var ur = G_NORMAL_MAP.getProjection().fromPixelToLatLng(urp,zoom);
    var dt = new Date();
    var nowtime = dt.getTime();

    var tileurl = "http://demo.remoteservice.com/cgi-bin/serve.cgi?";
        tileurl+="bbox="+ll.lng()+","+ll.lat()+","+ur.lng()+","+ur.lat();
        tileurl+="&width=256&height=256&reaspect=false&cachetime="+nowtime;

    return tileurl;
};

I got as far as:

var DemoLayer = new google.maps.ImageMapType({

     getTileUrl: function(coord, zoom) {

     var llp = new google.maps.Point(coord.x*256,(coord.y+1)*256);
     var urp = new google.maps.Point((coord.x+1)*256,coord.y*256);
     var ll = googleMap.getProjection().fromPointToLatLng(llp);
     var ur = googleMap.getProjection().fromPointToLatLng(urp);
     var dt = new Date();
     var nowtime = dt.getTime();

     var tileurl = "http://demo.remoteservice.com/cgi-bin/serve.cgi?";
         tileurl+="bbox="+ll.lng()+","+ll.lat()+","+ur.lng()+","+ur.lat();
  tileurl+="&width=256&height=256&reaspect=false&cachetime="+nowtime;

     return tileurl;

     },
             tileSize: new google.maps.Size(256, 256),
             opacity:1.0,
             isPng: true
         });

Specifically, I need help with this section:

var llp = new google.maps.Point(coord.x*256,(coord.y+1)*256);
 var urp = new google.maps.Point((coord.x+1)*256,coord.y*256);
 var ll = googleMap.getProjection().fromPointToLatLng(llp);
 var ur = googleMap.getProjection().fromPointToLatLng(urp);

The service wants the tile bounding box from what I understand. However, ll and ur do not seem to correct at all.

I had it working and displaying the entire map bounding box in each tile, but of course that’s not what I need.

Any insight here would be greatly appreciated, not having the GTileLayers in V3 is fine if I can work around it, until then I’m frustrated.

  • 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-15T05:58:29+00:00Added an answer on May 15, 2026 at 5:58 am

    The fix in my case was to use an updated tile service from the same publisher. It accepts simpler paramaters:

       globalfoovar = new google.maps.ImageMapType({
        getTileUrl: function(tile, zoom) {
            return "http://bar.com/" + zoom + "/" + tile.x + "/" + tile.y +".png"; 
        },
        tileSize: new google.maps.Size(256, 256),
        opacity:0.60,
        isPng: true
    });
    
    googleMap.overlayMapTypes.push(null); // create empty overlay entry
    googleMap.overlayMapTypes.setAt("0",globalfoovar); // set the overlay, 0 index
    
    // if you want to hide the layer later (toggle):
    // googleMap.overlayMapTypes.setAt("0",null);
    

    As you can see, this is much easier than the code I posted in the problem description.

    However if you’re still reading you probably still want the answer to the original problem, which is converting latlng to pixels. Don’t worry, I have a solution for that as well.

    To gain access to the 4 useful latlng, point, and pixel conversions you need to add a dummy OverlayView.

    Step 1) Define the stub so it is globally available, along with your map and other vars:

    var googleMap = {}; // global map var
    var mapCanvasStub = {}; // map OverlayView var
    

    Step 2) After you render your map, setup this dummy/stub OverlayView like so:

    googleMap = new google.maps.Map($('#mapCanvas')[0]); // google map init
    
    mapCanvasStub = function (map) { this.setMap(map); }  // start building overlay stub
    mapCanvasStub.prototype = new google.maps.OverlayView(); 
    mapCanvasStub.prototype.draw = function() {}; 
    mapCanvasStub = new mapCanvasStub(googleMap); // bin dthe overlay to the map
    

    Now you’ve got a functional OverlayView tied to the map, whenever you need to use those conversions you can do so like this:

    var projection = mapCanvasStub.getProjection();
    var position = projection.fromLatLngToContainerPixel( latLng );
                       // or fromContainerPixelToLatLng()
                       // or fromDivPixelToLatLng()
                       // or fromLatLngToDivPixel()
                       // or fromLatLngToDivPixel()
    

    In my case I’m using this to create custom info bubbles, here is a snippet from my click event:

    function customAlertClick(a,b,c) {
    
        var projection = mapCanvasStub.getProjection();
        var position = projection.fromLatLngToContainerPixel(b);
        var top = (position.y + parseInt($('#mapCanvas').position().top));
        var lft = (position.x + parseInt($('#mapCanvas').position().left));
    
        // obviously this is an overly simple example
        $('#foo').css('top',top + 'px');
        $('#foo').css('lft',left + 'px');
    }
    

    Hope this helps anyone else making the jump to V3.

    If you’re wondering why we have to jump through these extra hoops to do something that is so simple in V2, the answer is pretty obvious when you think about it. V3 is setup to work well on mobile devices where bandwidth and cpu power are limited. They’ve eliminated as much code as possible to get the simple maps rendering, and they expect you to manually wire up these extras if you absolutely need them.

    If I had more time I’d write a sample.html but this should get you going.

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

Sidebar

Related Questions

I need to update a combobox with a new value so it changes the
I need to update a record in a database with the following fields [ID]
I need to update a group of cells by inserting the same two characters
I need to update the comments field in a table for a large list
I need to update a field (which is currently empty) based on a match
So I need to update a text field. Neither the UPDATE statement or the
I'm trying to do the classic Insert/Update scenario where I need to update existing
I have a table of about a million rows and I need to update
I need write an update statement that used multiple tables to determine which rows
I have a Zimbra installation and I need to programmaticaly update contacts in it.

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.