simple google map problem

Discussion in 'Programming' started by harrisonford, Apr 18, 2008.

  1. #1
    hi ive go a small site that shows a map of the uk

    i have managed to show markers but having problems configuring the window that opens when clicked.

    cant figure out how to get a url into it.

    current code.... puts a moar into the map and a live window with the details
    " a brief encounter and LA6 2AJ"

    var point = new GPoint(-2.5773275,54.2217413889);
    var marker = createMarker(point, 'A Brief Encounter', 'LA6 2AJ');
    map.addOverlay(marker);

    what i need is

    A Brief Encounter
    LA6 2AJ
    web link


    thanks
     
    harrisonford, Apr 18, 2008 IP
  2. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use GLatLng instead of GPoint. Then use the following:



    function createMarker(point,html) {
    var marker = new GMarker(point);
    GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html);
    });
    return marker;
    }

    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(43.907787,-79.359741), 9);

    var point = new GLatLng( 43.65654,-79.90138);
    var marker = createMarker(point,'A Brief Encounter<br>LA6 2AJ<br><a href="http://www.somewebsite.com/">web link</a>')
    map.addOverlay(marker);
     
    GreatMetro, Apr 19, 2008 IP