Webkit mask moving when scrolling on chrome - html

I've been trying to make a rounded google map. I've finally achieved it and here is the jsfiddle
http://jsfiddle.net/DZTvR/13/
The problem is in chrome when I scroll, the mask remains in the same place while the map scrolls down.
I have tested on FF, opera safari and IE and it works great. It's just chrome
The HTML is
<div id="wrapp">
<div id="mask">
<div id="anyotherID"></div>
</div>
</div>
The JS
window.onload=function(){
var myLatlngDist = new google.maps.LatLng(-32.242741,-60.161446);
geocoder = new google.maps.Geocoder();
directionsService = new google.maps.DirectionsService();
var mapOptionsDist = {
zoom: 4,
center: myLatlngDist,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
mapDist = new google.maps.Map(document.getElementById('anyotherID'), mapOptionsDist);
}
The CSS
#anyotherID{
height:427px;
width:428px;
-webkit-border-radius: 1000px;
-moz-border-radius: 1000px;
border-radius: 1000px;
overflow: hidden;
}
#mask {
border-radius: 1000px;
-moz-border-radius: 1000px;
-webkit-border-radius: 1000px;
overflow: hidden;
position: absolute; /* this breaks the overflow:hidden in Chrome/Opera */
/* this fixes the overflow:hidden in Chrome */
-webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
}
Thanks for any help!

Got it to finally work here is how I fixed it
HTML:
<div id="wrapp">
<div id="mask">
<div id="anyotherID"></div>
</div>
<div style="clear:both;"></div>
</div>
Javascript:
var mapOptionsDist = {
zoom: 12,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.BOTTOM_CENTER
},
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
}
}
mapLoc = new google.maps.Map(document.getElementById('anyotherID'), mapOptionsDist);
And the css:
#anyotherID{
height:427px;
width:427px;
}
#mask {
border-radius: 1000px;
-moz-border-radius: 1000px;
-webkit-border-radius: 1000px;
height:427px;
width:427px;
overflow: hidden;
position: absolute; /* this breaks the overflow:hidden in Chrome/Opera */
-webkit-mask-image: url("/Resources/Image/px.png");
}
#wrapp{
height:427px;
width:427px;
float:left;
}
Just to clarify, the image px.png is just an image of a black pixel, without it, it won't work

Related

How to use CSS-only for cluster icons for Google Maps

My goal is to have CSS-only icons for my Google Maps marker clusters. I have seen in the documentation's "advanced example" (link) that CSS-only icons are possible. However, I have been unable to translate this example into my own project.
I have attempted to build a JSFiddle with my code, though I can not seem to initialize the map through JSFiddle due to API restrictions. When I run the code on my site, it adds numbers to the map, but no icons, as seen below.
I created some styles
var styles = [{
width: 30,
height: 30,
className: "custom-clustericon-1",
},
{
width: 40,
height: 40,
className: "custom-clustericon-2",
},
{
width: 50,
height: 50,
className: "custom-clustericon-3",
},
];
And I have attempted to initialize like this:
var markerCluster = new MarkerClusterer(map, markers,
{
styles: styles,
clusterClass: "custom-clustericon",
});
Where am I missing the mark here? I'd like to have marker icons exactly like the ones in the "advanced example", but I'm at a loss. I have searched extensively online for examples of css-only icons but could not find any standalone examples. Your help is kindly appreciated.
You are using the wrong version of the MarkerClusterer library.
Use this one:
<script src="https://googlemaps.github.io/js-markerclustererplus/dist/index.min.js"></script>
proof of concept fiddle
code snippet:
function map_initialize() {
var mapoptions = {
center: new google.maps.LatLng(0, 0),
zoom: 0,
maxZoom: 15,
mapTypeId: google.maps.MapTypeId.TERRAIN,
disableDefaultUI: true,
zoomControl: true,
scrollwheel: true
};
var styles = [{
width: 30,
height: 30,
className: "custom-clustericon-1",
},
{
width: 40,
height: 40,
className: "custom-clustericon-2",
},
{
width: 50,
height: 50,
className: "custom-clustericon-3",
},
];
var map = new google.maps.Map(document.getElementById("mapdivbig"),
mapoptions);
var infoWin = new google.maps.InfoWindow();
var bounds = new google.maps.LatLngBounds();
var markers = locations.map(function(location, i) {
bounds.extend(location);
map.fitBounds(bounds);
var marker = new google.maps.Marker({
position: location
});
google.maps.event.addListener(marker, 'click', function(evt) {
infoWin.setContent(location.info);
infoWin.open(map, marker);
})
return marker;
});
var markerCluster = new MarkerClusterer(map, markers, {
styles: styles,
clusterClass: "custom-clustericon",
});
}
var locations = [{
lat: 45.4208,
lng: -123.8,
info: 'Location 1'
},
{
lat: 47.6117,
lng: -122.345,
info: 'Location 2'
},
{
lat: 47.6308,
lng: -122.375,
info: 'Location 3'
}
]
html,
body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
#mapdivbig {
width: 100%;
height: 100%;
background-color: grey;
}
#mapdiv {
width: 100%;
height: 325px;
background-color: grey;
}
.custom-clustericon {
background: var(--cluster-color);
color: #fff;
border-radius: 100%;
font-weight: bold;
font-size: 15px;
display: flex;
align-items: center;
}
.custom-clustericon::before,
.custom-clustericon::after {
content: "";
display: block;
position: absolute;
width: 100%;
height: 100%;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
background: var(--cluster-color);
opacity: 0.2;
border-radius: 100%;
}
.custom-clustericon::before {
padding: 7px;
}
.custom-clustericon::after {
padding: 14px;
}
.custom-clustericon-1 {
--cluster-color: #00a2d3;
}
.custom-clustericon-2 {
--cluster-color: #ff9b00;
}
.custom-clustericon-3 {
--cluster-color: #ff6969;
}
<!DOCTYPE html>
<html>
<head>
<title>Marker Clustering</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<script src="https://googlemaps.github.io/js-markerclustererplus/dist/index.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&callback=map_initialize" defer></script>
<!-- jsFiddle will insert css and js -->
</head>
<body>
<div id="mapdivbig"></div>
</body>
</html>

set website background is google map iframe code

i need set iframe website background like this enter image description here
i went to show embed google map in background and add any think up it
<div id='map-canvas'><iframe
class="custom-google-map"
src="https://www.google.com/maps/d/embed?mid=1pqr-Kg5Dn8CyoomMIP2j7160niTmiTRi"
width="100%"
height="100%"
></iframe></div>
Remove iframe and add only this
<div id='map-canvas'></div>
And then Add this script in your html
$(document).ready(function() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
}
also add this css
#map-canvas {
height: 100%;
position: absolute;
top: 0;
bottom: -200px;
left: 0;
right: 0;
z-index: 0;
}
#container {
z-index: 100;
position: relative;
}

Streetview placeholder is here, but Pegman is missing

I've integrate the googlemaps api
but Pegman is missing from the streetview little white square (bottom right)
I've notice that some div that hold the pegman icon in googlemaps code have height and width equal at 0px
what can I do to fix that ?
Here's a sample of how I called and initiate my map
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_KEY"></script>
Here's my map component :
<div class="map-box" id="map" #map></div>
with css.js looking like
.map-box {
height: 100%;
width: 100%;
}
and how I create it :
var ownPos = {lat: -4.85, lng: 2.35};
this.mapDisplay = new google.maps.Map(document.getElementById('map'), {zoom: 4, center: ownPos, streetViewControl: true});
I had this same issue and solved it with some CSS:
/* Force position to show pegman */
.gm-svpc div img {
position: relative !important;
}
fixing of wrappers' height solved the same bug
agm-map {
height: 425px;
& /deep/ .gm-svpc { //dispayed pegman's icon on map
div {
height: 40px;
}
}
}
/* there are actually two `<div>`s, with the 2nd one actually holding the symbol */
.gm-svpc > div:last-of-type {
/* same dimensions as symbol child element */
width: 32px;
height: 32px;
}

Google Maps overflow through box on iOS

I have problem with diplaying google map in circle on iOS systems. Map is overflowing box where it is included. It is a bug, or I do not know... Do you know some hack on that? Bug image.
My HTML code is pretty simple and looks like div.g-map>div.map where is rendered Google Map by JS.
CSS:
.map {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/* It has to be circle! */
.g-map {
position: relative;
width: 262px;
height: 262px;
border-radius: 50%;
overflow: hidden;
}
Try to avoid the use of absolute positioning if you can.
You still have an outer and inner blocks with same size.
Here is the fiddle, please try to open it in your browser:
https://jsfiddle.net/svitch/zb1fg48f/10/
And here is the code:
function initMap() {
var uluru = {lat: -25.363, lng: 131.044};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: uluru,
disableDefaultUI: true
});
var marker = new google.maps.Marker({
position: uluru,
map: map
});
}
#map, #g-map {
height: 262px;
width: 262px;
}
/* It's a circle */
#g-map {
border: none;
border-radius: 50%;
overflow: hidden;
}
<div id="g-map"><div id="map"></div></div>
<!-- Replace the value of the key parameter with your own API key. -->
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=&callback=initMap">
</script>
SOLUTION:
Just add z-index: 10; to .map and in iOS browsers map will not overflow circle.
.map {
z-index: 10;
...
}

Google maps API not displaying in full size

I use jQuery mobile for my iOS application. Here is what it happens inside when I load the map:
I have used the following script in order to generate this.
var map
var mark
function initialize() {
var latlng = new google.maps.LatLng(52.404657,-1.491413);
var myOptions = {
zoom: 13,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
mark = new google.maps.Marker( {
position: latlng,
map:map
})
}
function mostrarUbicacion(){
navigator.geolocation.getCurrentPosition( lecturaGPS , errorGPS , {enableHighAccuracy:true} )
}
function lecturaGPS(ubicacion){
var miubicacion = new google.maps.LatLng(ubicacion.coords.latitude, ubicacion.coords.longitude);
map.setCenter(miubicacion)
mark.setPosition(miubicacion)
}
function errorGPS(){
alerta(" unable to connect")
}
html:
<body onload="initialize()" style="height:100%">
<div id="map_canvas" style="width:100%; height:50%; padding:0;"></div>
<button onClick="mostrarUbicacion()"> Click to find where you are! </button>
</body>
try to set the div for the map and the css this way:
HTML:
<div class="Flexible-container" id="map" style="margin:1.5%;">
<!-- this is the div for the map -->
</div>
CSS:
/* Flexible iFrame */
.Flexible-container {
position: relative;
padding-bottom: 32.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.Flexible-container iframe,
.Flexible-container object,
.Flexible-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
to adjust the width of the div use percentages; you can adjust the height setting padding-bottom.
here the doc