This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

dijo.dill
dijo.dill

Hello! I created a contact page with a map section and the marker.png is set in javascript, but the png file is not loading.

    var marker = new google.maps.Marker({
        position: new google.maps.LatLng(40.6700, -73.9400),
        map: map,
        icon: "assets/img/icon/map-marker.png",
        title: 'ContactMap'
    }); 

Can you please help me?

mjauvin
mjauvin

Where did you put that JavaScript?

If the asset you're referencing is under the theme's assets folder, you need to give the full path like:

icon: "/themes/<your-theme-name>/assets/img/icon/map-marker.png"
dijo.dill
dijo.dill

That JavaScript is in the theme's assets folder and I tried your solution, but it didn't help.

Then I put that function into the layout file, within a script tag at the end and used |theme to navigate to that png and it worked.

Thanks a lot mjauvin!

   <script>                                                                                                                                   
    var marker = new google.maps.Marker({
    position: new google.maps.LatLng(40.6700, -73.9400),
    map: map,
    icon: "{{'assets/img/icon/map-marker.png'|theme}}",
    title: 'ContactMap'
    });                                                                                                                                   
    </script>
mjauvin
mjauvin

Yes, that's a much better way to do it!

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.