Refreshing Google map until new data has been added to the database
In my opinion the best way to achieve what you want is to work with Event Listeners.

So basically, breaking it down to software design, you would fire a event if something is written to the database, so everytime you insert into the database. Maybe also when you update or delete something if you want to trigger these too.

Then you need an Event Listener which will run php code which runs and does what you want when new Data is added only when new Data is added.

Then you could send frequently requests to the PHP file, which gives you the message back if data is updated or not, but that would be counterproductive behavior because your already working event driven.

So you fire a Response to the JavaScript from the PHP file when the Event got fired. So your whole code will only run if it must, which depends only on if there's new data or not. Without continious requests whatsoever.

This would be the best attempt, you'll need some things for that, like the before mentioned Event Listeners, jQuery Ajax Calls or Plain JavaScript Ajax Calls.

Also some thougts to your SQL code

$count1 = $_POST['count']; //NEVER use data from Requests directly! 


You're vulnerable to SQL Injection! Always escape the input and use prepared statements

$count2 = $count1+1; //Attempting to the above code there's no need for this line


And at least you can mix these 2 lines togther to one line:

$sql = mysql_query("SELECT id_history FROM tb_history");
$count3 = mysql_num_rows($sql);


Would be

$count3 = mysql_query("SELECT count(id_history) FROM tb_history");