Logo Hardware.com.br
Wellinghton Pereira Gomes
Wellinghton... Membro Junior Registrado
81 Mensagens 4 Curtidas

[Resolvido] Ajuda com CSS

#1 Por Wellinghton... 25/02/2020 - 13:50
Boa tarde pessoal. Estou fazendo um mapa com inúmeros registros e dados.
Acontece que estou usando um xml com os dados e fazendo com que apareça num infowindow.

criei um arquivo css e gostaria de saber como faço para controlar o estilo dentro do infowindow com esse css.
por exemplo: trocar a cor dos texto ou tamanho e tal...
Obs estou usando o brackets, e tem uma imagem para vcs verem como fica.



segue o codigo:
<!DOCTYPE html >
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}

</style>
</head>

<html>
<body>
<div id="map"></div>
<script>

function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(-27.131034, -51.468336),
zoom: 14
});
var infoWindow = new google.maps.InfoWindow;

// Change this depending on the name of your PHP or XML file
downloadUrl('testtt.xml'
//'https://storage.googleapis.com/mapsdevsite/json/mapmarkers2.xml'
, function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName('marker');
Array.prototype.forEach.call(markers, function(markerElem) {
var id = markerElem.getAttribute('id');
var name = markerElem.getAttribute('name');
var data = markerElem.getAttribute('data');
var address = markerElem.getAttribute('address');
var numero = markerElem.getAttribute('numero');
var foto = markerElem.getAttribute('foto');
var gg = markerElem.getAttribute('google');
var lb = markerElem.getAttribute('lb');
var type = markerElem.getAttribute('type');
var point = new google.maps.LatLng(
parseFloat(markerElem.getAttribute('lat')),
parseFloat(markerElem.getAttribute('lng')));

var infowincontent = document.createElement('div');


var text0 = document.createElement('strong');
text0.textContent = id
infowincontent.appendChild(text0);
infowincontent.appendChild(document.createElement('p'));

var text1 = document.createElement('text1');
text1.textContent = name
infowincontent.appendChild(text1);
infowincontent.appendChild(document.createElement('br'));

var text2 = document.createElement('text2');
text2.textContent = data
infowincontent.appendChild(text2);
infowincontent.appendChild(document.createElement('br'));

var text3 = document.createElement('text3');
text3.textContent = address
infowincontent.appendChild(text3);
infowincontent.appendChild(document.createElement('br'));

var text4 = document.createElement('text4');
text4.textContent = numero
infowincontent.appendChild(text4);
infowincontent.appendChild(document.createElement('br'));

var text5 = document.createElement('text5');
text5.textContent = foto
infowincontent.appendChild(text5);
infowincontent.appendChild(document.createElement('br'));




var marker = new google.maps.Marker({
map: map,
position: point

});
marker.addListener('click', function() {
infoWindow.setContent(infowincontent);
infoWindow.open(map, marker);
});
});
});
}



function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;

request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};

request.open('GET', url, true);
request.send(null);
}

function doNothing() {}
</script>

<script async defer
src="https://maps.googleapis.com/maps/api/js?key=SUA_API_AQUI&callback=initMap">
</script>
</body>
</html>


Consegui evoluir... trocando algumas coisas dentro das variáveis.

em vez de colocar: text2.textContent
eu troco por: text2.innerHTML

isso me permitiu colocar as coisas que eu queria atraves das tags e tal...
só queria agora saber se da pra aumentar o tamanho da fonte...

var text2 = document.createElement('text2');
text2.innerHTML = '    Data: '+data
infowincontent.appendChild(text2);
infowincontent.appendChild(document.createElement('br'));

var text3 = document.createElement('text3');
text3.innerHTML = '+link+'
infowincontent.appendChild(text3);
infowincontent.appendChild(document.createElement('br'));

Mais uma atualização

Se eu colocar uma div dentro ali, funciona os parâmetros de font-size-removed, color etc...
obs não pode esquecer de fechar a tag

var text2 = document.createElement('text2');
text2.innerHTML = '
    Data: '+data+'
'
infowincontent.appendChild(text2);
infowincontent.appendChild(document.createElement('br'));

Apesar de não ter sido por um arquivo CSS consegui fazer o que eu queria

Anexos

© 1999-2024 Hardware.com.br. Todos os direitos reservados.
Imagem do Modal