I’ve followed this example: Javascript newbie: Help implementing a script, and i’ve managed to get it to work(ish) on my wordpress site(I want the default map to be the first marker, how can I do that?)
The trouble is, I currently have this within a page text area. This is causing issues as it doesn’t like the addition of tags within the script as WordPress adds others as well. My WordPress tends to automatically add a ‘p’ tag for every return!
Is there another way of achieving this? Possibly putting the code into a javascript file then calling it on the page? I think that’s the right way, but can anybody help me as i’m stuck with that.
One way would be to create a special page template within your WP theme, with the necessary HTML/JS for the map, and then applying that template to the page where you want the map to appear. The benefit of doing it this way is that the code can’t be broken by anyone accidentally when editing the page content.
An alternative would be to skip using maplacejs (which is a jQuery plugin) and use one of the WP google maps plugins available. I don’t remember the name now, but there is one that allows you to easily add map pins from the admin page.
One last thing, I’ve used that script that is mentioned in my first post. For some random reason, the street view area is all squashed and disappears when you hover over it. Is there an easier way to get the zoom area and the street view bit (from the top left usually) to show correctly?
Do you have the code online somewhere I could take a look at it? Or, failing that, could you post the code here (or in a codepen) so I can recreate the problem?
I’ve created a page with the example code in and it seems to work OK for me. Perhaps you have some other CSS included in your page that is interfering with the map controls?