dynamic image path within a javascript file

If you’re in JS you can’t use PHP (<?php ?>), you need to another way to get a PHP variable into JS. The normal way with WordPress is to use wp_localize_script().

wp_localize_script( 'wpse_274344', 'myScriptObject', array(
    'markerImageUrl' => get_theme_file_uri( '/img/mapmarker.png' ),
) );

Add that code after your call to wp_enqueue_script() or wp_register_script(). Replace wpse_274344 with the name you used when enqueuing the script.

This means that WordPress will output a JavaScript object named myScriptObject to the page containing the values that you passed to wp_localize_script().

Then in your script file you can access the markerImageUrl like this:

markerImage = {
    url: window.myScriptObject.markerImageUrl
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)