• Google Mashups, pt. 2

    Posted on April 22nd, 2009 jmstovall No comments

    The goal of this effort is only to get a map on a page and get a marker on a page…seems pretty easy. As promised, there’s some serious googling to be done, and I came up with this page: InformIT article.

    So this seems to work pretty well, although the first few steps I’ve already figured out from Google’s API documentation (seems it taught me more than I realized). What I really need is some very basic code to get started so I can pull my coordinates out and start playing:

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=APIKEY" type="text/javascript"></script>
    <script type="text/javascript"><!--

    function load() {
    if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(LATITUDE, LONGITUDE), ZOOM);
    }
    }
    // --></script>

    and…

    var point = new GLatLng(LATITUDE,LONGITUDE)
    map.addOverlay(new GMarker(point));

    So that gets me started, and after adding minimal styling information, I come up with this: first version of map.

    Mission accomplished, it seems, so I decide to try for one more step: adding an info window. Incredibly easy: second version of map.

    Well, the tutorial is pretty step-by-step, but I’m finding that because of the Rails work, I can follow the what the code is doing much more easily. That still doesn’t mean I’m able to extrapolate and figure too much new stuff on my own, but it makes following the API docs easier.

    Leave a reply