Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

in gmap3 dont show marker in map when i include marker code inside a map as below

jquery
map: {
                    options: {
                        center: { lat: 8.558058925477096, lng: 76.87785568237302 },
                        zoom: 5

                    },

                    marker:
                            {
                                latLng: [8.561840136925703, 76.87608003616333]

                            }

                }

});


But show marker in map when code outside map

jquery
$("#map_canvas").gmap3({

                map: {
                    options: {
                        center: { lat: 8.558058925477096, lng: 76.87785568237302 },
                        zoom: 5

                    }
                    },
                    marker:
                            {
                                latLng: [8.561840136925703, 76.87608003616333]

                            }

});



How to show marker with first option.bcz i want to show marker in each click event in map

as below

jquery
$("#map_canvas").gmap3({

                map: {
                    options: {
                        center: { lat: 8.558058925477096, lng: 76.87785568237302 },
                        zoom: 5

                    },
                    event:
                    {
                        click: function (map, event, data) {
                            marker:
                            {
                                latLng: [event.latLng.lat(), event.latLng.lng()]

                            }

                        }
                    }

                }

});
Posted

1 solution

I solved this problem by calling a separate function from click event


jquery
            $("#map_canvas").gmap3({
                map: {
                    options: {
                        center: { lat: 8.558058925477096, lng: 76.87785568237302 },
                        zoom: 5
                    },
                    events:
                    {
                        click: function (map, event, data) {
                            check(event);
                        }
                    }
                }

});


 function check(event) {
                $("#map_canvas").gmap3({

                    marker:
               {
                   latLng: [event.latLng.lat(), event.latLng.lng()]
               }
                });
            }


thanks god..thank god...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900