Posted in

Integración de GoogleMaps v2 (OBSOLETO)

Ejemplo de integración de Google Maps mediante una Api que te asignan ellos, el ejemplo de aquí abajo es mas actual que la demo.

En el head:

<head>    
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key=ABQIAAAAfForovJ3R9LenV0xN0XE8xQj90hRVl3ZD85pD3uHumwmKqn8IRSegZderywtVll9KBYhW8UaAU4MXA" type="text/javascript"></script>
    <script type="text/javascript"> 
    // Create a directions object and register a map and DIV to hold the 
    // resulting computed directions
    
    var map;
      var geocoder;
      function findLocation() {
      geocoder.getLocations("Folgueroles, 4, 08022 Barcelona", addAddressToMap);
      }
      
      function load() {
      map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      map.setMapType(G_HYBRID_MAP);
      map.setCenter(new GLatLng(3.278344, 42.288548), 16);
      geocoder = new GClientGeocoder();  
         findLocation();
      }
      
      function addAddressToMap(response) {
      map.clearOverlays();
             if (!response || response.Status.code != 200) {
                 
            map.openInfoWindowHtml(map.getCenter(),"<strong style='color:#ee3a42; font-size:12px;'>¡¡No existe dirección para este contacto!!</strong><br><img src='images/error2.png'>");
    
             } else {
             
            place = response.Placemark[0];
            point = new GLatLng(place.Point.coordinates[1],
            place.Point.coordinates[0]);
            marker = new GMarker(point);
            map.addOverlay(marker);
            marker.openInfoWindowHtml('<div style="border-bottom:1px solid #333; font-weight:bold;">Escola de Música Sant Gervasi</div><div style="margin-top:3px; font-size:12px; font-weight:bold;">Carrer de Folgueroles, 4<br>08022 Barcelona, España</div>');
            
      }
      }         
    </script>
</head>

En el body:

<div id="map" style="width:579px; height:240px; float:none; margin:0px 0px 0px 0px;"></div>

Deixa un comentari

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *


The reCAPTCHA verification period has expired. Please reload the page.