Phuket IT

Computer => Web Site => Topic started by: admin on 24, 08, 2013, 09:33:13

Title: Marker content (infoWindow) Google Maps
Post by: admin on 24, 08, 2013, 09:33:13
Marker content (infoWindow) Google Maps
(http://media.svennerberg.com/2008/12/infowindow.png)

Code: [Select]
var hotels = [
            ['ibis Birmingham Airport', 52.452656, -1.730548, 4, 'Ambassador Road<br />Bickenhill<br />Solihull<br />Birmingham<br />B26 3AW','(+44)1217805800','(+44)1217805810','info@ibisbhamairport.com','http://www.booknowaddress.com'],
            ['ETAP Birmingham Airport', 52.452527, -1.731644, 3, 'Ambassador Road<br />Bickenhill<br />Solihull<br />Birmingham<br />B26 3QL','(+44)1217805858','(+44)1217805860','info@etapbhamairport.com','http://www.booknowaddress.com'],
            ['ibis Birmingham City Centre', 52.475162, -1.897208, 2, 'Ladywell Walk<br />Birmingham<br />B5 4ST','(+44)1216226010','(+44)1216226020','info@ibisbhamcity.com','http://www.booknowaddress.com']
        ];

        for (var i = 0; i < hotels.length; i++) {
            var marker = new google.maps.Marker({
                position: new google.maps.LatLng(hotels[i][1], hotels[i][2]),
                map: map,
                icon: image,
                title: hotels[i][0],
                zIndex: hotels[i][2]
            });

            var infoWindow = new google.maps.InfoWindow();

            google.maps.event.addListener(marker, 'click', function () {
                var markerContent = hotels[i][4];
                infoWindow.setContent(markerContent);
                infoWindow.open(map, this);
            });
        }


Code: [Select]
function addInfoWindow(marker, message) {
            var info = message;

            var infoWindow = new google.maps.InfoWindow({
                content: message
            });

            google.maps.event.addListener(marker, 'click', function () {
                infoWindow.open(map, marker);
            });
        }

addInfoWindow(marker, hotels[3]);

ref - http://stackoverflow.com/questions/5868903/marker-content-infowindow-google-maps
Title: Re: Marker content (infoWindow) Google Maps
Post by: constance on 01, 04, 2014, 11:02:42
แจ่มเลยครับ
Title: Re: Marker content (infoWindow) Google Maps
Post by: kukkainakornphun on 28, 12, 2014, 22:03:55
แจ่มเลยค่ะ ขอบคุณที่แชร์เทคนิคนี้ค่ะ