2

I'd like to set up a Google Map or any other map with pins in certain locations and have those pins link to other websites.

Anyone know how I can do that?

1 Answer 1

1

You can use the following code:

<script type="text/javascript">
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 5,
      center: new google.maps.LatLng(0,0),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var MyPlace = new google.maps.LatLng(18, 78);

    var marker = new google.maps.Marker({
        position: MyPlace,
        url: 'http://www.wikipedia.org/',
        title: 'This link opens Wikipedia home page',
        map: map
    });

    google.maps.event.addListener(marker, 'click', function() {
      window.location.href = marker.url;
    });

  </script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.