I try to put some rectangles on a styled map which can be zoomed in and out. I noticed that every time I change the zoom level from e.g. 17.5 to 17.6, the streets are changing their width and because of that the rectangle changes its position compared to the street.
Code:
map
var latlng = new google.maps.LatLng(lat, lng); var myOptions = { zoom: zoom, center: latlng, disableDefaultUI: true, scrollwheel: false, disableDoubleClickZoom: true, styles: [ { featureType: 'all', stylers: [{visibility: "off"}] }, { featureType: 'landscape', stylers: [{color: "#000000"}, {visibility: "on"}] }, { featureType: 'road', elementType: 'geometry', stylers: [{color: '#ffffff'}, {visibility: "on"}, {weight: 2}] } ] }; map = new google.maps.Map(document.getElementById('map'), myOptions);rectangle
var rectangle = new google.maps.Rectangle({ fillColor: '#FF0000', fillOpacity: 1, strokeColor: '#FF0000', strokeWeight: 2, strokeOpacity: 1, map: map, bounds: { north: lat1, south: lat2, west: lng1, east: lng2 } });
I want the rectangle to be in the same place of the street at the all zoom levels. Can this be done?
PS. Here's what it looks like: zoom=19.5 vs zoom=19.6
EDIT:
I forgot to mention that step-like changing width only occurs when crossing 0.5 - if I change the zoom from 19.2 to 19.3 there is no difference in positions.
See the example:
zoom=21.1 vs zoom=21.3
I also noticed that rectangle's stroke seems to change its weight less often that the street's one. Can somebody explain the reason of such behavior?
strokeWeightparameter?