locked
small content window RRS feed

  • Question

  • User639567535 posted

    i try to plotting data on google map and i am done with this now the problem is there is 4000+ records in table so plotting this  data on map through cluster a

    this is what i try

    var map;                 
                        debugger;
                        var latlng = new google.maps.LatLng(94.0895898, 87.0998546);
                        debugger;
                        var myOptions = {
                            zoom: 8,
                            center: latlng,
                            mapTypeId: google.maps.MapTypeId.ROADMAP
                        };
                        debugger;
                        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                        
                        var markers = [];
                        for (i = 0; i < d.length - 1; i++) {
                            var myLatlng = new google.maps.LatLng(d[i][5], d[i][4]);
                            var marker = new google.maps.Marker({
                                ,
                                        //icon: "images/car.png",
                                        map: map,
                                        title: 'Click me'
                            });
                            markers.push(marker);
                        }
                        var MarkerClusterer = new MarkerClusterer(map,markers,{imagePath: 'images/m1'});
                      
                            debugger;
                            var infowindow = new google.maps.InfoWindow({
                                content: 'Lat:' + d[i][5] + '<br>Long:' + d[i][4]
                            });
                            marker.addListener('click', function () {
                            })
                            google.maps.event.addListener(marker, 'click', function () {
                                infowindow.open(map, marker, data);
                            });
                            infowindow.open(map, marker, data);
                        

    I try this but info window is not display when i open map page .. i want when i open page then small window is display with lat and long values and when i close this window and again click on marker then window should appear 

    Friday, October 7, 2016 5:20 AM

Answers

  • User1435244517 posted

    Hi Bakhtawar

    I noticed that you referenced the marker object, but that marker was created within the for loop.

    Since it was created in a different scope it would not be available.

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

    My suggestion would be to move this code into for loop where you created the marker object and added it to the array.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 13, 2016 3:08 AM

All replies

  • User1324658857 posted

    hi ,

    you can look up this link ,

    Google map API:

    https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple

    Monday, October 10, 2016 2:07 PM
  • User1435244517 posted

    Hi Bakhtawar

    I noticed that you referenced the marker object, but that marker was created within the for loop.

    Since it was created in a different scope it would not be available.

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

    My suggestion would be to move this code into for loop where you created the marker object and added it to the array.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 13, 2016 3:08 AM