Cześć przyjaciele, nie mogę znaleźć rozwiązania dla pliku map-active.js Myślę, że ekspert JS może to łatwo zrobić, czy możesz mi pomóc, udostępnię plik map-active.js tutaj tylko wspomnij o jednej lokalizacji, którą chcę dodać jeszcze jedną lokalizację, jak to możliwe ...?

// google map
function initialize() {
	 var grayStyles =[{"featureType":"water","elementType":"geometry","stylers":[{"color":"#e9e9e9"},{"lightness":17}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#ffffff"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#ffffff"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":16}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":21}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#dedede"},{"lightness":21}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#ffffff"},{"lightness":16}]},{"elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#333333"},{"lightness":40}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#f2f2f2"},{"lightness":19}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#fefefe"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#fefefe"},{"lightness":17},{"weight":1.2}]}] 
	var mapOptions = {
	zoom: 12,
	styles: grayStyles,
	hue: '#E9E5DC',
	scrollwheel: false,
		center: new google.maps.LatLng(9.967027, 76.243499),
		
	};
	var map = new google.maps.Map(document.getElementById('googleMap'),
	mapOptions);
	  var marker = new google.maps.Marker({
		position: map.getCenter(),
		animation:google.maps.Animation.BOUNCE,
		icon: './assets/img/map.png',
		map: map
	});  
}
google.maps.event.addDomListener(window, 'load', initialize);    
-2
Lijo Mattathil 6 grudzień 2018, 07:04

1 odpowiedź

Najlepsza odpowiedź

Tak jak dodałeś pierwszą lokalizację, w ten sam sposób utwórz nowe znaczniki dołączone do tej samej mapy.

var marker1 = new google.maps.Marker({
        position: {lat: LOCATION_1_LAT, lng: LOCATION_1_LON},
        animation:google.maps.Animation.BOUNCE,
        icon: './assets/img/map.png',
        map: map
    });

var marker2 = new google.maps.Marker({
            position: {lat: LOCATION_2_LAT, lng: LOCATION_2_LON},
            animation:google.maps.Animation.BOUNCE,
            icon: './assets/img/map.png',
            map: map
        });

Demo tutaj: https://jsfiddle.net/sz9gkox6/

2
M A 6 grudzień 2018, 07:27