I am trying to display Google Maps markers with a circular icon as a SVG path.
I have this HTML:
<div id="map-canvas"></div>
And this javascript:
function initialize() {
let mapOptions = {
zoom: 4,
center: new google.maps.LatLng(48, 20)
}
let map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions)
let circle = {
path: 'M 1, 2 a 1,1 0 1,1 2,0 a 1,1 0 1,1 -2,0',
anchor: new google.maps.Point(2, 2),
scale: 10
}
let marker = new google.maps.Marker({
position: map.getCenter(),
icon: circle,
map: map
})
}
google.maps.event.addDomListener(window, 'load', initialize);
Google Maps renders the SVG path as an img
tag inside a div
tag.
Without touchscreen, both tags have calculated dimensions width: 30px; height: 30px;
, which is as expected (in all browsers I tested).
But on a laptop with touchscreen there are some unexpected margins rendered. Both img
and div
tag have calculated dimensions width: 46px; height: 46px;
. Both in Chrome and Firefox:
How can I prevent this difference? Is there a way to override the setting window.navigator['maxTouchPoints']
of the client?
Edit: "Device Manager -> Human Interface Devices -> HID-compliant touch screen -> Disable" seems to cause window.navigator['maxTouchPoints'] = 0
and the issue is gone. Is there any other workaround, which keeps the touchscreen functionality outside of the webpage?
When I draw two markers close to each other, hovering over the marker with lower z-index
causes the tooltip of the other marker to show up due to the margin.
I have tried setting a circular MarkerShape
but the problem remains: http://jsfiddle.net/shrt8axj/
Edit: I ended up opening a new issue with Google.