Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    caricare info window direttamente senza click mouse

    salve a tutti,io ho trovato in internet qst codice ke mi sarebbe utile,l'unica cosa è ke a me servirebbe ke la info window si aprisse senza dover cliccare col mouse sul marker,ma direttamente quando si carica la mappa,come posso fare??

    ecco il codice:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Google Maps</title>

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAxsvyvIkFFylo tQgsc5AKCBSwvKeh809S4dNqSwFjVL5jHrr9ihTIDeC-0nLy4lmOP4eyGSJbfS9AmQ" type="text/javascript"></script>
    <style type="text/css">
    <!--
    body {
    background-image: url(../211124472_67122da021_o.jpg);
    }
    -->
    </style></head>

    <body onunload="GUnload()">


    <div id="map" style="width: 550px; height: 450px; border: 1px solid #000000;"></div>

    <noscript>JavaScript must be enabled in order for you to use Google Maps.

    However, it seems JavaScript is either disabled or not supported by your browser.

    To view Google Maps, enable JavaScript by changing your browser options, and then
    try again.


    </noscript>
    <script type="text/javascript">
    //<![CDATA[
    if (GBrowserIsCompatible()) {
    // this variable will collect the html which will eventually be placed in the GMapSidebar
    var GMapSidebar_html = "";

    // arrays to hold copies of the markers and html used by the GMapSidebar
    // because the function closure trick doesnt work there
    var gmarkers = [];
    var htmls = [];
    var i = 0;
    // arrays to hold variants of the info window html with get direction forms open
    var to_htmls = [];
    var from_htmls = [];
    // A function to create the marker and set up the event window
    function createMarker(point,name,html) {
    var marker = new GMarker(point);
    // The info window version with the "to here" form open
    to_htmls[i] = html + '
    Come Raggiungerci: ' +
    '
    Indirizzo di Partenza:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
    '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" />
    ' +
    '<INPUT value="Calcola Percorso" TYPE="SUBMIT">' +
    '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() +
    // "(" + name + ")" +
    '"/>';

    // The inactive version of the direction info
    html = html + '
    Come Raggiungerci ';
    GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html);
    });
    // save the info we need to use later for the GMapSidebar
    gmarkers[i] = marker;
    htmls[i] = html;
    // add a line to the GMapSidebar html
    GMapSidebar_html += '' + name + '
    ';
    i++;
    return marker;
    }

    // This function picks up the click and opens the corresponding info window
    function myclick(i) {
    gmarkers[i].openInfoWindowHtml(htmls[i]);
    }
    // functions that open the directions forms
    function tohere(i) {
    gmarkers[i].openInfoWindowHtml(to_htmls[i]);
    }

    // create the map
    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(45.9595,8.8731), 14);

    // Read the data from map.xml
    var request = GXmlHttp.create();
    request.open("GET", "map.xml", true);
    request.onreadystatechange = function() {
    if (request.readyState == 4) {
    var xmlDoc = request.responseXML;
    // obtain the array of markers and loop through it
    var markers = xmlDoc.documentElement.getElementsByTagName("marke r");

    for (var i = 0; i < markers.length; i++) {
    // obtain the attribues of each marker
    var lat = parseFloat(markers[i].getAttribute("lat"));
    var lng = parseFloat(markers[i].getAttribute("lng"));
    var point = new GLatLng(lat,lng);
    var html = markers[i].getAttribute("html");
    var label = markers[i].getAttribute("label");
    // create the marker
    var marker = createMarker(point,label,html);
    map.addOverlay(marker);
    }
    // put the assembled GMapSidebar_html contents into the GMapSidebar div
    document.getElementById("GMapSidebar").innerHTML = GMapSidebar_html;
    }
    }
    request.send(null);
    }
    else {
    alert("Sorry, the Google Maps API is not compatible with this browser");
    }
    // This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/
    // http://www.econym.demon.co.uk/googlemaps/
    //]]>
    </script>




    grazie mille

  2. #2
    ho risolto...ecco come ho modificato il codice,magari a qualcuno puo tornare utile...






    // The info window version with the "to here" form open

    map.openInfoWindowHtml(point,to_htmls[i] = html + '
    Come Raggiungerci: ' +

    '
    Indirizzo di Partenza:<form action="http://maps.google.com/maps" method="get" target="_blank">' +

    '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" />
    ' +

    '<INPUT value="Calcola Percorso" TYPE="SUBMIT">' +

    '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() +

    // "(" + name + ")" +

    '"/>');

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.