Add google map with dot mark (longitude, latitude)

0

I want to add a map with a mark on my ASP.NET page, this code adds the map but not the point, what will I be doing wrong?

   function CreateMapGoogle() {

            var atrMap = {
                center: new google.maps.LatLng(40.712449, -74.001508),
                zoom: 14,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };

            var map = new google.maps.Map(document.getElementById("idgoogleMap"), atrMap);
            var myLatLng = { lat: 40.712449, lng: -74.001500};
            var i=0;

                var marker = new google.maps.Marker({
                    map: map,
                    animation: google.maps.Animation.DROP,
                    icon: 'x.png',
                    title: 'MI TITULO',
                    position: myLatLng
                });
                marker.setMap(map);
                (function (marker, i) {

                    google.maps.event.addListener(marker, 'click', function () {

                        infowindow = new google.maps.InfoWindow({ maxWidth: 250 });
                        infowindow.setContent('MI UBICACION NOMBRE');
                        infowindow.open(map, marker);

                    });

                })(marker, i);

    }
    
asked by Efrain Mejias C 04.09.2016 в 19:30
source

1 answer

2

What I see is that you assign the map to the Marker but also you realize the setMap() , when it should be one way or another not both

Bookmarks

if you use the setMap () you only use this

var myLatLng = { lat: 40.712449, lng: -74.001500};

var atrMap = {
            center: myLatLng,
            zoom: 4
        };

var map = new google.maps.Map(document.getElementById("idgoogleMap"), atrMap);

var marker = new google.maps.Marker({
    animation: google.maps.Animation.DROP,
    icon: 'x.png',
    title: 'MI TITULO',
    position: myLatLng
});

marker.setMap(map);

also discusses the example

Simple markers

try removing the% share% of% to see if it is generating an error in javascript that prevents the marker from being represented

    
answered by 05.09.2016 / 19:05
source