SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Cambs
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Passing data to functions GoogleMap

    Hope someone on here can help me as I am a bit lost.

    I am trying to use gmap and have worked out how to post postcodes but now infotext.

    This is the gmap.js
    var map;
    var localSearch = new GlocalSearch();

    var icon = new GIcon();
    icon.image = "http://www.google.com/mapfiles/marker.png";
    icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    icon.iconSize = new GSize(20, 34);
    icon.shadowSize = new GSize(37, 34);
    icon.iconAnchor = new GPoint(10, 34);
    icon.infoWindowAnchor = new GPoint(19,0);




    function usePointFromPostcode(postcode, callbackFunction) {

    localSearch.setSearchCompleteCallback(null,
    function() {

    if (localSearch.results[0])
    {
    var resultLat = localSearch.results[0].lat;
    var resultLng = localSearch.results[0].lng;
    var point = new GLatLng(resultLat,resultLng);
    callbackFunction(point);
    }else{
    alert("Postcode not found!");
    }
    });

    localSearch.execute(postcode + ", UK");
    }

    var address_0 = {
    street: '',
    city: '',
    state: '',
    zip: '',
    country: 'UK',
    infowindow: 'default',
    infowindowtext: '<span style="font: 10px Verdana, Arial, Helvetica, sans-serif; color: #000;">Member Car</span>',
    full: '',
    isdefault: true
    };


    function placeMarkerAtPoint(point)
    {
    var marker = new GMarker(point,icon);
    GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(address_0.infowindowtext);
    });
    map.addOverlay(marker);
    }

    function setCenterToPoint(point)
    {
    map.setCenter(point, 17);
    }

    function showPointLatLng(point)
    {
    alert("Latitude: " + point.lat() + "\nLongitude: " + point.lng());
    }

    function mapLoad() {
    if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));


    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(54.622978,-2.592773), 5, G_HYBRID_MAP);
    }
    }

    function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
    window.onload = func;
    } else {
    window.onload = function() {
    oldonload();
    func();
    }
    }
    }

    function addUnLoadEvent(func) {
    var oldonunload = window.onunload;
    if (typeof window.onunload != 'function') {
    window.onunload = func;
    } else {
    window.onunload = function() {
    oldonunload();
    func();
    }
    }
    }

    addLoadEvent(mapLoad);
    addUnLoadEvent(GUnload);

    This is what I am sending to it

    <script language="javascript">
    <%
    While ((Repeat1__numRows <> 0) AND (NOT rsUsers.EOF))
    %>
    var loc = '<%=(rsUsers.Fields.Item("Postcode").Value)%>';
    var car = '<%=(rsUsers.Fields.Item("Car").Value)%>';
    usePointFromPostcode(loc, placeMarkerAtPoint)
    <%
    Repeat1__index=Repeat1__index+1
    Repeat1__numRows=Repeat1__numRows-1
    rsUsers.MoveNext()
    Wend
    %>
    </script>

    I want to be able to send the var car to the infowindowtext: in gmap.js

    Any help gratefully received.

    James
    Last edited by microimage; Mar 7, 2008 at 01:20. Reason: change title


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •