Ir para conteúdo
Fórum Script Brasil
  • 0

não consigo fazer codigo funcionar


Rodrigao

Pergunta

Bom dia a todos,

alguém pode me ajudar a ver o que estou fazendo de errado? Sou iniciante em html e não to conseguindo resolver isso, já perdi umas noites de sono.

<script src="http://maps.google.com/?file=api&amp;v=2.x&amp; key=' + Quotedstr(gkey) + '''' + ' type="text/javascritp"></scritp>

<script type="text/javascript">

var map;

var gdir;

var geocoder = null;

var addressMarker;

function initialize()

{

if (GBrowserIsCompatible())

{

map= new GMap2(document.getElementById("map_canvas"));

gdir = new GDirections(map,document.getElementById("directions"));

GEvent.addListener(gdir, "addoverlay", onGDirectionsLoad);

GEvent.addListener(gdir, "error", handleErrors);

setDirections(' + '''' + AOrigem + '''' + ',' + '''' + ADestino + '''' + ','+'''' + ALocalidade + '''' + ');

}

}

function setDirections(fromAddress, toAddress, locale) {

gdir.load("from: " + fromAddress + " to: " + toAddress,

{ "locale": locale });

}

function onGDirectionsLoad() {

var poly = gdir.getPolyline();

if (poly.getVertexCount() > 100) {

alert("Esta rota possui muitos vertices.");

return;

}

var baseUrl = "http://maps.google.com/staticmap?";

var params = [];

params.push("center=" + map.getCenter().lat().toFixed(6) + "," + map.getCenter().lgn().toFixed(6));

var markersArray = [];

markersArray.push(poly.getVertex(0).toUrlValue(5) + "greena");

markersArray.push(poly.getVertex(poly.gerVertexCount() -1).toUrlValue(5) + ", greenb");

params.push("markers=" + markersArray.join("|"));

var polyParams ="rgba:0x0000FF80,weight:5|";

var polyLatLngs = [];

for (var j = 0; j < poly.getVertexCount(); j++) {

polyLatLngs.push(poly.getVertex(j).lat().toFixed(5) + "," + poly.getVertex(j).lng().toFixed(5));

}

params.push("path=" + polyParams + polyLatLngs.join("|"));

params.push("zoom=" + map.getZoom());

params.push("size=310x400");

var img = document.createElement("img");

img.src = baseUrl + params.join("&") + "&key='+ gKey + '";

document.getElementById("staticMapIMG").innerHTML = "";

document.getElementById("staticMapIMG").appendChild(img);

document.getElementById("staticMapURL").innerHTML = baseUrl + params.join("&") + "&key=YOUR_KEY_HERE";

}

</script>

</head>

<body onload="initialize()" onunload="GUnload()">

<h2>Exemplo Mapas Clube Delphi</h2>

<form action="#" onsubmit="setDirections(' + '''' + AOrigem + '''' + ',' + '''' + ADestino + '''' + ','+'''' + ALocalidade + '''' '); return false">

<input type="hidden" size="25" id="fromAddress" name="from" value="' + '''' + AOrigem + '''' + '"

<input type="hidden" size="25" id="toAddress" name="to" value="' + '''' + ADestino + '''' +'"

</form>

<br/>

<table class="directions">

<tr><th>Direções</th><Mapa</th></tr>

<tr>

<td valign="top"><div id="directions" style="width:275px"></div></td>

<td valign="top"><div id="map_canvas" style="width:500px"; height: 450px"></div></td>

</tr>

</table>

<div id="staticMapIMG" style="width: 500px; margin-left: 20px; height: 410px"></div>

<br clear="all"/>

<h3><img src="http://www.google.com/uds/solutions/wizards/img/3b.gif"

style="vertical-align:middle"/>Generate URL</h3>

<p>The Static Maps Api requires a free API key thats associated with your

<a href="http://www.google.com/accounts/"> Google Account</a> and the URL of your web site.

You can sign up for one <a

href="http://code.google.com/apis/maps/signup.html">here</a>, and substitute it

as teh value of the "&key=" parameter in te URL below.

<br/>

<p>

</p>

pre id="staticMapURL" class=-"code">

</pre>

</body>

</html>

Se puderem me ajudar

Agradecido

Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0
Cara, eu to vendo só de relance seu código, já vo ter que sair !!! ... mas não será algum erro relacionada a digitação ?? .. Logo na segunda linha vi sua tag errada ... </scritp>

opa boa noite

fiz as correções sugeridas mas mesmo assim

ainda continua não funcionando

AT.

Rodrigo

Link para o comentário
Compartilhar em outros sites

  • 0

Também tem outros erros de digitação no código na mesma linha

Você definiu o type como text/javascritp

Tente deixar assim

<script src="http://maps.google.com/?file=api&amp;v=2.x&amp; key=' + Quotedstr(gkey) + '''' + ' type="text/javascript"></script>

Obs.:

Peço que modifique seu código e inclua as tag's [html] e [/html] (facilita a visualização)

Link para o comentário
Compartilhar em outros sites

  • 0

Ke Nojo desse código...

Copia e cola esse e ve se da certo.

<script src="http://maps.google.com/?file=api&amp;v=2.x&amp; key=' + Quotedstr(gkey) + '''' + '" type="text/javascript"></script>
<script type="text/javascript">
var map;
var gdir;
var geocoder = null;
var addressMarker;
function initialize()
{
if (GBrowserIsCompatible())
{
map= new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map,document.getElementById("directions"));
GEvent.addListener(gdir, "addoverlay", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);
setDirections(' + '''' + AOrigem + '''' + ',' + '''' + ADestino + '''' + ','+'''' + ALocalidade + '''' + ');
}
}
function setDirections(fromAddress, toAddress, locale) {
gdir.load("from: " + fromAddress + " to: " + toAddress,
{ "locale": locale });
}
function onGDirectionsLoad() {
var poly = gdir.getPolyline();
if (poly.getVertexCount() > 100) {
alert("Esta rota possui muitos vertices.");
return;
}
var baseUrl = "http://maps.google.com/staticmap?";
var params = [];
params.push("center=" + map.getCenter().lat().toFixed(6) + "," + map.getCenter().lgn().toFixed(6));
var markersArray = [];
markersArray.push(poly.getVertex(0).toUrlValue(5) + "greena");
markersArray.push(poly.getVertex(poly.gerVertexCount() -1).toUrlValue(5) + ", greenb");
params.push("markers=" + markersArray.join("|"));
var polyParams ="rgba:0x0000FF80,weight:5|";
var polyLatLngs = [];
for (var j = 0; j < poly.getVertexCount(); j++) {
polyLatLngs.push(poly.getVertex(j).lat().toFixed(5) + "," + poly.getVertex(j).lng().toFixed(5));
}
params.push("path=" + polyParams + polyLatLngs.join("|"));
params.push("zoom=" + map.getZoom());
params.push("size=310x400");
var img = document.createElement("img");
img.src = baseUrl + params.join("&") + "&key='+ gKey + '";
document.getElementById("staticMapIMG").innerHTML = "";
document.getElementById("staticMapIMG").appendChild(img);
document.getElementById("staticMapURL").innerHTML = baseUrl + params.join("&") + "&key=YOUR_KEY_HERE";
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<h2>Exemplo Mapas Clube Delphi</h2>
<form action="#" onsubmit="setDirections(' + '''' + AOrigem + '''' + ',' + '''' + ADestino + '''' + ','+'''' + ALocalidade + '''' '); return false">
<input type="hidden" size="25" id="fromAddress" name="from" value="' + '''' + AOrigem + '''' + '"
<input type="hidden" size="25" id="toAddress" name="to" value="' + '''' + ADestino + '''' +'"
</form>
<br/>
<table class="directions">
<tr><th>Direções</th><Mapa</th></tr>
<tr>
<td valign="top"><div id="directions" style="width:275px"></div></td>
<td valign="top"><div id="map_canvas" style="width:500px"; height: 450px"></div></td>
</tr>
</table>
<div id="staticMapIMG" style="width: 500px; margin-left: 20px; height: 410px"></div>
<br clear="all"/>
<h3><img src="http://www.google.com/uds/solutions/wizards/img/3b.gif"
style="vertical-align:middle"/>Generate URL</h3>
<p>The Static Maps Api requires a free API key thats associated with your
<a href="http://www.google.com/accounts/"> Google Account</a> and the URL of your web site.
You can sign up for one <a
href="http://code.google.com/apis/maps/signup.html">here</a>, and substitute it
as teh value of the "&key=" parameter in te URL below.
<br/>
<p>
</p>
<pre id="staticMapURL" class="code">
</pre>
</body>
</html>

Editado por DeeKilleer
Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...