I'm trying to create a shortcode that lets you embed google map anywhere in wordpress page.
shortcode must be able to pass two attributes ( latitude and longitude )
Below is edited question ( I did not edit whole question as there exists answer for above question )
Adding shortcode wasn't suitable choice in my case as there were be multiple locations ( markers on map ).
So, I need to create a map that would load multiple locations.
This is not only problem, there are three places ( eg, place1, place2, place3 ) and each location contains sub locations. The map should load place1 locations when page loads, when clicked on other place tab ( say place2 ) the map should hide place1 locations and load the locations of place2, and same for place3. And finally there exists a tab to load all the places and theri respective locations.
google.maps.event.addDomListener(window, 'load', init);
function init() {
// Basic options for a simple Google Map
// For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions
var mapOptions = {
// How zoomed in you want the map to start at (always required)
zoom: 6,
// The latitude and longitude to center the map (always required)
center: new google.maps.LatLng(62.1630198, 12.9895886), // New York
// How you would like to style the map.
// This is where you would paste any style found on Snazzy Maps.
styles: [{"featureType":"administrative","elementType":"all","stylers":
[{"saturation":"-100"}]},{"featureType":"administrative.province",
"elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"landscape",
"elementType":"all","stylers":[{"saturation":-100},{"lightness":65},
{"visibility":"on"}]},{"featureType":"poi","elementType":"all","stylers":
[{"saturation":-100},{"lightness":"50"},{"visibility":"simplified"}]},
{"featureType":"road","elementType":"all","stylers":[{"saturation":"-100"}]},
{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":
"simplified"}]},{"featureType":"road.arterial","elementType":"all","stylers":
[{"lightness":"30"}]},{"featureType":"road.local","elementType":"all","stylers":
[{"lightness":"40"}]},{"featureType":"transit","elementType":"all","stylers":
[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"water",
"elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},
{"saturation":-97}]},{"featureType":"water","elementType":"labels","stylers":
[{"lightness":-25},{"saturation":-100}]}]
};
// Get the HTML DOM element that will contain your map
// We are using a div with id="map" seen below in the <body>
var mapElement = document.getElementById('map');
// Create the Google Map using our element and options defined above
var map = new google.maps.Map(mapElement, mapOptions);
// Let's also add a marker while we're at it
var marker = new google.maps.Marker({
position: new google.maps.LatLng(40.6700, -73.9400),
map: map,
title: 'Location One'
});
var marker = new google.maps.Marker({
position: new google.maps.LatLng(43.6700, -73.9400),
map: map,
title: 'Location Two'
});
var marker = new google.maps.Marker({
position: new google.maps.LatLng(46.6700, -73.9400),
map: map,
title: 'Location Three'
});
}
I'm using ACF to make fields for longitude and latitude values for locations.