{"id":4093,"date":"2019-08-01T19:35:13","date_gmt":"2019-08-01T19:35:13","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=4093"},"modified":"2019-08-01T19:45:05","modified_gmt":"2019-08-01T19:45:05","slug":"google-maps-dynamic-custom-marker-icons-with-php-mysql-database","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/","title":{"rendered":"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL"},"content":{"rendered":"<p><b>Google Maps API<\/b> provides an easy way to embed the map on the web page. The specific location can be marked on the Google Map using a marker. The marker with InfoWindow helps to add some information about the location. You can add multiple markers with InfoWindow to the Map using Google Maps JavaScript API.<\/p>\n<p><b>Google Map with multiple markers<\/b> is very useful when you want to add multiple locations in a single map. Generally, static markers are added to Google Maps. But, if you want to add dynamic locations from the database, it can be easily done with PHP and MySQL. You can <a href=\"https:\/\/www.codexworld.com\/adding-multiple-markers-with-info-windows-to-google-maps-dynamically-from-database\/\">add multiple markers with Info Window to Google Map<\/a> dynamically from the database with PHP and MySQL. In this tutorial, we will show you how to add custom markers with Info Window to Google Maps dynamically from the database using PHP and MySQL.<\/p>\n<p>In the example code, we will implement the following functionality.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Embed Google Maps on the website.<\/li>\n<li>Fetch dynamic locations from the database.<\/li>\n<li>Add multiple markers with Info Window to the Google Map.<\/li>\n<li>Fetch dynamic marker icons from the database.<\/li>\n<li>Change and add custom icon\/images to markers.<\/li>\n<\/ul>\n<h2>Get an API Key<\/h2>\n<p>An API key is required to use the Google Maps JavaScript API. You need to specify the API key on API call to authenticate with Google Maps JavaScript API. So, before you begin to embed Google Map on the website, create an API key on the Google Developers Console.<\/p>\n<ul class=\"step_list\">\n<li>Go to the <a href=\"https:\/\/console.developers.google.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Google Developers Console<\/a>.<\/li>\n<li>Select the project from the Project drop-down menu at the top. If you don&#8217;t have an existing project, create a new one.<\/li>\n<li>In the left navigation pane, select the <b>APIs &#038; Services &raquo; Credentials<\/b>.<\/li>\n<li>In the Credentials page, select <b>Create credentials &raquo; API key<\/b>.<\/li>\n<li>The API key will be created and a dialog will appear with newly created API key.<\/li>\n<\/ul>\n<p>Copy the <b>API key<\/b> for later use in the script on Google Maps JavaScript API request.<\/p>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/get-google-maps-javascript-api-key\/\">How to Get Google Maps JavaScript API Key<\/a><\/span><\/p>\n<h2>Create Database Table<\/h2>\n<p>To store the dynamic locations information and marker images a table is required in the database. The following SQL creates a <code>locations<\/code> table with some basic fields in the MySQL database.<\/p>\n<pre style=\"color: rgb(0, 0, 0);\"><span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">TABLE<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`locations`<\/span> (\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> AUTO_INCREMENT,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`latitude`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">20<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`longitude`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">20<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">100<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`info`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">255<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`icon`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">255<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COMMENT<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'Marker icon'<\/span>,\r\n PRIMARY <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span>)\r\n) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CHARSET<\/span>=utf8 <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span>=utf8_unicode_ci;<\/pre>\n<h2>Database Configuration (dbConfig.php)<\/h2>\n<p>The <code>dbConfig.php<\/code> file is used to connect and select the database. Specify the database host (<code>$dbHost<\/code>), username (<code>$dbUsername<\/code>), password (<code>$dbPassword<\/code>), and name (<code>$dbName<\/code>) as per your MySQL database credentials.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Database&nbsp;configuration <br \/><\/span><span style=\"color: #0000BB\">$dbHost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"localhost\"<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$dbUsername&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"root\"<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$dbPassword&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"root\"<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$dbName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"codexworld\"<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Create&nbsp;database&nbsp;connection <br \/><\/span><span style=\"color: #0000BB\">$db&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">mysqli<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$dbHost<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbUsername<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbPassword<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbName<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;connection <br \/><\/span><span style=\"color: #007700\">if&nbsp;(<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;die(<\/span><span style=\"color: #DD0000\">\"Connection&nbsp;failed:&nbsp;\"&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">); <br \/>}<\/span><\/pre>\n<h2>Fetch Location and Marker Image Info from Database<\/h2>\n<p>The latitude and longitude are fetched from the database using PHP and MySQL.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>The first result set is used to generate multiple markers and custom icons information (location, latitude, longitude, and icon image source).<\/li>\n<li>The second result set is used to generate the content of the info windows.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;database&nbsp;configuration&nbsp;file <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #DD0000\">'dbConfig.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Fetch&nbsp;the&nbsp;marker&nbsp;info&nbsp;from&nbsp;the&nbsp;database <br \/><\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"SELECT&nbsp;*&nbsp;FROM&nbsp;locations\"<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Fetch&nbsp;the&nbsp;info-window&nbsp;data&nbsp;from&nbsp;the&nbsp;database <br \/><\/span><span style=\"color: #0000BB\">$result2&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"SELECT&nbsp;*&nbsp;FROM&nbsp;locations\"<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Add Multiple Markers with Custom Images<\/h2>\n<p>Load the Google Map JavaScript API and specify an API key in the <code>key<\/code> parameter.<\/p>\n<pre>&lt;<span style=\"color:#bf4f24\">script<\/span> <span style=\"color:#bf4f24\">src<\/span>=<span style=\"color:#0b6125\">\"https:\/\/maps.googleapis.com\/maps\/api\/js?key=<span style=\"border:2px solid #FB4314; font-weight:bold; border-style:dashed;\">Your_API_KEY<\/span>\"<\/span>&gt;&lt;\/<span style=\"color:#bf4f24\">script<\/span>&gt;<\/pre>\n<p>The following JavaScript code adds multiple markers with custom icons to Google Map from the database in PHP.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>The <b>initMap()<\/b> is a custom JavaScript function that initializes Google Maps.<\/li>\n<li>Define the Google Maps object and attach the map to the HTML element.<\/li>\n<li>Fetch the latitude, longitude, and marker icon image URL from the database and generate position array for multiple markers (<code>markers<\/code>).<\/li>\n<li>Fetch the location info from the database and generate array for the content of info windows (<code>infoWindowContent<\/code>).<\/li>\n<li>Add multiple markers with dynamic locations and custom icon to Google Map.<\/li>\n<li>Add info window with dynamic content to the markers.<\/li>\n<li>Set zoom level of the Google Map.<\/li>\n<\/ul>\n<p>Load <code>initMap()<\/code> function to initialize the Google Map.<\/p>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">script<\/span>&gt;<\/span>\r\n<span style=\"color: rgb(110, 107, 94);\"><span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span> <span class=\"hljs-title\" style=\"color: rgb(102, 132, 225);\">initMap<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\"><\/span>) <\/span>{\r\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> map;\r\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> bounds = <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">new<\/span> google.maps.LatLngBounds();\r\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> mapOptions = {\r\n        mapTypeId: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'roadmap'<\/span>\r\n    };\r\n                    \r\n    <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Display a map on the web page<\/span>\r\n    map = <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">new<\/span> google.maps.Map(<span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">document<\/span>.getElementById(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"mapCanvas\"<\/span>), mapOptions);\r\n    map.setTilt(<span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">100<\/span>);\r\n        \r\n    <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Multiple markers location, latitude, and longitude<\/span>\r\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> markers = [<span class=\"xml\">\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">num_rows&nbsp;<\/span><span style=\"color: #007700\">&gt;&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while(<\/span><span style=\"color: #0000BB\">$row&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fetch_assoc<\/span><span style=\"color: #007700\">()){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'[\"'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'\",&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'latitude'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">',&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'longitude'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">',&nbsp;\"'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'icon'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'\"],'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n    ];\r\n                        \r\n    \/\/ Info window content\r\n    var infoWindowContent = [\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">$result2<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">num_rows&nbsp;<\/span><span style=\"color: #007700\">&gt;&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while(<\/span><span style=\"color: #0000BB\">$row&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$result2<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fetch_assoc<\/span><span style=\"color: #007700\">()){&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n                ['<span class=\"hljs-tag\" style=\"color: rgb(215, 55, 55);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(215, 55, 55);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"info_content\"<\/span>&gt;<\/span>' +\r\n                '<span class=\"hljs-tag\" style=\"color: rgb(215, 55, 55);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(215, 55, 55);\">h3<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(215, 55, 55);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(215, 55, 55);\">h3<\/span>&gt;<\/span>' +\r\n                '<span class=\"hljs-tag\" style=\"color: rgb(215, 55, 55);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(215, 55, 55);\">p<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'info'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(215, 55, 55);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(215, 55, 55);\">p<\/span>&gt;<\/span>' + '<span class=\"hljs-tag\" style=\"color: rgb(215, 55, 55);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(215, 55, 55);\">div<\/span>&gt;<\/span>'],\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n    ];\r\n        \r\n<span style=\"color: rgb(110, 107, 94);\">    <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Add multiple markers to map<\/span>\r\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> infoWindow = <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">new<\/span> google.maps.InfoWindow(), marker, i;\r\n    \r\n    <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Place each marker on the map  <\/span>\r\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">for<\/span>( i = <span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">0<\/span>; i &lt; markers.length; i++ ) {\r\n        <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> position = <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">new<\/span> google.maps.LatLng(markers[i][<span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">1<\/span>], markers[i][<span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">2<\/span>]);\r\n        bounds.extend(position);\r\n        marker = <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">new<\/span> google.maps.Marker({\r\n            position: position,\r\n            map: map,\r\n\t\t\ticon: markers[i][<span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">3<\/span>],\r\n            title: markers[i][<span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">0<\/span>]\r\n        });\r\n        \r\n        <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Add info window to marker    <\/span>\r\n        google.maps.event.addListener(marker, <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'click'<\/span>, (<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\">marker, i<\/span>) <\/span>{\r\n            <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">return<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\"><\/span>) <\/span>{\r\n                infoWindow.setContent(infoWindowContent[i][<span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">0<\/span>]);\r\n                infoWindow.open(map, marker);\r\n            }\r\n        })(marker, i));\r\n\r\n        <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Center the map to fit all markers on the screen<\/span>\r\n        map.fitBounds(bounds);\r\n    }\r\n\r\n    <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Set zoom level<\/span>\r\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> boundsListener = google.maps.event.addListener((map), <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'bounds_changed'<\/span>, <span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\">event<\/span>) <\/span>{\r\n        <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">this<\/span>.setZoom(<span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">14<\/span>);\r\n        google.maps.event.removeListener(boundsListener);\r\n    });<\/span>\r\n}\r\n\r\n<span style=\"color: rgb(110, 107, 94);\"><span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Load initialize function<\/span>\r\ngoogle.maps.event.addDomListener(<span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">window<\/span>, <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'load'<\/span>, initMap);<\/span>\r\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">script<\/span>&gt;<\/span><\/pre>\n<h2>Embed Google Map with Custom Marker Icons<\/h2>\n<p>Define an HTML element to embed the Google Map with multiple markers and Info Windows on the web page. Specify the element ID (<code>mapCanvas<\/code>) in the Google Map object.<\/p>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"mapCanvas\"<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span><\/pre>\n<h2>CSS Code<\/h2>\n<p>Use CSS to set the height and weight of the Google map container.<\/p>\n<pre style=\"color: rgb(0, 0, 0);\"><span class=\"hljs-selector-id\" style=\"color: green;\">#mapCanvas<\/span> {\r\n    <span class=\"hljs-attribute\" style=\"color: maroon;\">width<\/span>: <span class=\"hljs-number\" style=\"color: navy;\">100%<\/span>;\r\n    <span class=\"hljs-attribute\" style=\"color: maroon;\">height<\/span>: <span class=\"hljs-number\" style=\"color: navy;\">650px<\/span>;\r\n}<\/pre>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/autocomplete-location-search-box-google-maps-javascript-api-jquery-ui\/\">Autocomplete Location Search using Google Maps JavaScript API and jQuery<\/a><\/span><\/p>\n<h2>Conclusion<\/h2>\n<p>Google Map marker icon can be easily changed using JavaScript. Use our example script to change and add a custom image to marker icons in Google Maps. You can add markers and icons dynamically from the database with PHP and MySQL. Not only the marker but also you can add dynamic content to info window of the Google Map.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Maps API provides an easy way to embed the map on the web page. The specific location can be marked on the Google Map using a marker. The marker with InfoWindow helps to add <\/p>\n","protected":false},"author":1,"featured_media":4095,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[109],"tags":[15,35,19,14],"class_list":["post-4093","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-googlemap","tag-google-maps","tag-google-maps-api","tag-mysql","tag-php","cat-109-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL - CodexWorld<\/title>\n<meta name=\"description\" content=\"Google Maps multiple markers and dynamic icons - Add custom icon to marker dynamically from the database. Add dynamic markers with custom icons and info window using PHP and MySQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Google Maps multiple markers and dynamic icons - Add custom icon to marker dynamically from the database. Add dynamic markers with custom icons and info window using PHP and MySQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-01T19:35:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-08-01T19:45:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/08\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL\",\"datePublished\":\"2019-08-01T19:35:13+00:00\",\"dateModified\":\"2019-08-01T19:45:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/\"},\"wordCount\":721,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png\",\"keywords\":[\"Google Maps\",\"Google Maps API\",\"MySQL\",\"PHP\"],\"articleSection\":[\"GoogleMap\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/\",\"name\":\"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png\",\"datePublished\":\"2019-08-01T19:35:13+00:00\",\"dateModified\":\"2019-08-01T19:45:05+00:00\",\"description\":\"Google Maps multiple markers and dynamic icons - Add custom icon to marker dynamically from the database. Add dynamic markers with custom icons and info window using PHP and MySQL.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png\",\"width\":1366,\"height\":768,\"caption\":\"add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL - CodexWorld","description":"Google Maps multiple markers and dynamic icons - Add custom icon to marker dynamically from the database. Add dynamic markers with custom icons and info window using PHP and MySQL.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/","og_locale":"en_US","og_type":"article","og_title":"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL - CodexWorld","og_description":"Google Maps multiple markers and dynamic icons - Add custom icon to marker dynamically from the database. Add dynamic markers with custom icons and info window using PHP and MySQL.","og_url":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2019-08-01T19:35:13+00:00","article_modified_time":"2019-08-01T19:45:05+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/08\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL","datePublished":"2019-08-01T19:35:13+00:00","dateModified":"2019-08-01T19:45:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/"},"wordCount":721,"commentCount":3,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/08\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png","keywords":["Google Maps","Google Maps API","MySQL","PHP"],"articleSection":["GoogleMap"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/","url":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/","name":"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/08\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png","datePublished":"2019-08-01T19:35:13+00:00","dateModified":"2019-08-01T19:45:05+00:00","description":"Google Maps multiple markers and dynamic icons - Add custom icon to marker dynamically from the database. Add dynamic markers with custom icons and info window using PHP and MySQL.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/08\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/08\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png","width":1366,"height":768,"caption":"add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/google-maps-dynamic-custom-marker-icons-with-php-mysql-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Add Custom Marker Icons to Google Map Dynamically from the Database with PHP and MySQL"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/08\/add-multiple-markers-with-info-windows-to-google-maps-from-database-php-mysql-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-141","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/4093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=4093"}],"version-history":[{"count":4,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/4093\/revisions"}],"predecessor-version":[{"id":4099,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/4093\/revisions\/4099"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/4095"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=4093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=4093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=4093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}