I have a tile map like this .I would like to know the lat and long values (41.850033,-87.6500523) is located inside which tileBounds?
Am getting tile bounds values for every tile. but i dont know how to check if latitude is inside the range of particular tileBound value. how to find?
here is a working copy of my code
http://jsfiddle.net/doktormolle/55Nke/
var div = ownerDocument.createElement('div');
div.innerHTML =
'<pre><strong>tile:\n['+tile.x+','+tile.y+']</strong>\
\nbounds:{\nsw:['+tileBounds.sw.lat+','+tileBounds.sw.lng+'],\
\nne:['+tileBounds.ne.lat+','+tileBounds.ne.lng+']\n}</pre>';
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';
if(lat === 41.850033 && lng === -87.6500523){ //if latitude and longitude value inside that tile bounds set color as red
div.style.backgroundColor='red';
}
return div;
};
how to check here if my latitude and longitude lies inside tileBounds.sw and tileBounds.ne?
var setTileBackground =
this.mapDataPoints.some(function(el){
return (tileBounds.sw.lat <= el.latitude <= tileBounds.ne.lat && tileBounds.sw.lng <= el.longitude <= tileBounds.ne.lng)
}) // never returns true ...
I solved my problem with this check
var setTileBackground = this.mapDataPoints.some(function(el){
return (el.latitude > tileBounds.sw.lat && el.latitude < tileBounds.ne.lat && el.longitude > tileBounds.sw.lng &&
el.longitude < tileBounds.ne.lng)
});