Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle maps mapType coordinates
    primarykey
    data
    text
    <p>I've got a little problem here.</p> <h2>What i want to do.</h2> <p>On my server i have a table with markers that have lat, lng, <a href="http://msdn.microsoft.com/en-us/library/bb259689.aspx" rel="nofollow noreferrer">tile</a> fields in it. There are a lot of markers in table so i request them by tiles that are visible to the user. To make it working as it should is my final goal.</p> <h2>Problem</h2> <p>I wanted to solve this by creating my own <a href="https://developers.google.com/maps/documentation/javascript/maptypes?hl=#CustomMapTypes" rel="nofollow noreferrer">mapType</a> and define method <code>getTile()</code> that will be responsible for requesting appropriate tiles from server using <code>x/y/z</code> notation where x,y are the coordinates of tile and z is the zoom level. More about this you can find <a href="https://developers.google.com/maps/documentation/javascript/maptypes?hl=en#TileCoordinates" rel="nofollow noreferrer">here</a>. There is my code(i'm using <a href="http://code.google.com/p/jquery-ui-map/" rel="nofollow noreferrer">jquery-ui-map plugin</a> here):</p> <pre><code>function ServerFetchMapType() { this.tileSize = new google.maps.Size(256,256); this.maxZoom = 15; this.name = "Server Tile #s"; this.alt = "Server Data Tile Map Type"; this.getTile = function(coord, zoom, ownerDocument){ //Data for request var x = coord.x; var y = coord.y; var z = zoom; //Here i will make an ajax request for markers in this tile //Visualization var div = ownerDocument.createElement('DIV'); div.innerHTML = 'X:' + coord.x + ' Y:' + coord.y + ' Z:' + zoom; div.style.width = this.tileSize.width + 'px'; div.style.height = this.tileSize.height + 'px'; div.style.fontSize = '10'; div.style.borderStyle = 'solid'; div.style.borderWidth = '1px'; div.style.borderColor = '#AAAAAA'; return div; }; } var test = new ServerFetchMapType(); $('#map_canvas').gmap(); $('#map_canvas').gmap('get', 'map').overlayMapTypes.insertAt(0, test); </code></pre> <p>Everything worked but then i found one drawback, i will illustrate it:</p> <p><img src="https://i.stack.imgur.com/boLQZ.png" alt="enter image description here"></p> <p>As you can see only 4 tiles in the center of the picture have the <a href="https://developers.google.com/maps/documentation/javascript/maptypes?hl=en#TileCoordinates" rel="nofollow noreferrer">right</a> <code>x/y/z</code> notation and therefore all the tiles that are descendants of this tiles. But i won't be able to use other tiles to fetch data from server.</p> <h2>Question</h2> <p>So what can i do to change coordinates of other tiles where the map is just repeating to have the same coordinates as main tiles? Or you can offer other way to solve this. Any help will be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload