This may be a surprise, but you're actually not using any JSON. The Styled
Map Wizard's "Show JSON" button is incorrectly labeled. It generates a
JavaScript object literal. The Wizard *could* generate valid JSON code by
simply quoting the property names as JSON syntax requires - but it doesn't
matter for the typical kind of JavaScript code you have here - an ordinary
object literal is fine.

I mention this only because it's a common point of confusion. JSON is more
or less a stricter subset of the object literal notation (indeed it gets its
name from that notation), but they're not exactly the same.

So is the question how to move your JavaScript code to a separate .js file?
Take *all* of the content of your <script> tag - everything between <script>
and </script> - and move it to a .js file. Then put the path to your .js
file in the <script> tag's src attribute. Let's say your .js file is called
mymap.js and it's in a js subdirectory - then you would use:

<script src="js/mymap.js">
</script>

Don't do anything special and different with the map styles object literal -
just copy it along with the rest of your JS code.

Anyway, this isn't really a Maps API question, but there are other groups
and forums where you can get answers to more general HTML/JavaScript
questions like this.

-Mike

On Sun, Jul 24, 2011 at 9:15 AM, Carta <s...@cartagram.com> wrote:

> I'm beginning to learn how to customize Google Maps. I did some
> customization in Google's Styled Map Wizard and exported the JSON code
> and customized it more. The map is at
> http://www.cartagram.com/maps/madisonal/madisonal.html
>
> Question: a book I'm reading on Google Maps suggests keeping a
> seperate folder for the javascript and for the css. So I've been
> trying to convert the JSON code to a .js file and running it from a
> simplified .html file with a link to the .css and the .js.
>
> No luck.
>
> Any suggestions?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to
> google-maps-js-api-v3@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-api-v3+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to