?
Solved

Styled Google Maps

Posted on 2013-10-30
5
Medium Priority
?
231 Views
Last Modified: 2013-11-25
I'm trying to change the map colour in the right nav on this page according to Google's specifications here under the 'Style Array Example' with grey features and blue roads.

I've tried everything it says, but still can't get it to work.

Here's the HTML:
          <div style="width:100%;height:215px;background:url(http://maps.google.com/maps/api/staticmap?center=<%=server.URLEncode(""&rs("ca_postcode"))%>&zoom=14&size=350x350&maptype=roadmap&markers=color:ORANGE|label:A|<%=server.URLEncode(""&rs("ca_postcode"))%>&sensor=false) center no-repeat;"></div>

Open in new window

0
Comment
Question by:UName10
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39612166
This is very similar to the question you posted here.

Here is a working example based on that question's posted code, incorporating the code you posted. I changed the inline server side code to real numbers for the sake of the example.
<!DOCTYPE html>
<html> 
<head> 
   <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
   <title>Google Maps -- Styled Map</title> 
   <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head> 
<body onLoad="initialize()"> 
      <div id="map-canvas" style="width:100%;height:215px;background:url(http://maps.google.com/maps/api/staticmap?center=55.6468,37.581&zoom=14&size=350x350&maptype=roadmap&markers=color:ORANGE|label:A55.6468,37.581&sensor=false) center no-repeat;"></div>

<script type="text/javascript">
function initialize() {

  // Create an array of styles.
  var styles = [
    {
      stylers: [
        { hue: "#00ffe6" },
        { saturation: -20 }
      ]
    },{
      featureType: "road",
      elementType: "geometry",
      stylers: [
        { lightness: 100 },
        { visibility: "simplified" }
      ]
    },{
      featureType: "road",
      elementType: "labels",
      stylers: [
        { visibility: "off" }
      ]
    }
  ];

  // Create a new StyledMapType object, passing it the array of styles,
  // as well as the name to be displayed on the map type control.
  var styledMap = new google.maps.StyledMapType(styles,
    {name: "Styled Map"});

  // Create a map object, and include the MapTypeId to add
  // to the map type control.
  var mapOptions = {
    zoom: 14,
    center: new google.maps.LatLng(55.6468, 37.581),
    mapTypeControlOptions: {
      mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style']
    }
  };
  var map = new google.maps.Map(document.getElementById('map-canvas'),
    mapOptions);

  //Associate the styled map with the MapTypeId and set it to display.
  map.mapTypes.set('map_style', styledMap);
  map.setMapTypeId('map_style');
}
</script>
          
</body> 
</html>

Open in new window

0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 1500 total points
ID: 39612286
In looking at the link you provided, the inline server side code (<%=server.URLEncode(""&rs("ca_postcode"))%>) is producing this: CM15+8AG,
which is not something Google Maps is going to be able to translate into longitude/latitude coordinates.

Also, you cannot, as far as I know, style a map generated from a link. You have to create a styled map using the Google Maps API as I have demonstrated. Basically, most of what you have in that div is not being used in my example. This is really all that matters:
<div id="map-canvas" style="width:100%;height:215px;"></div>
The script does the rest.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39674333
I've requested that this question be closed as follows:

Accepted answer: 500 points for tommyBoy's comment #a39612166

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 

Author Closing Comment

by:UName10
ID: 39674334
Valid answer for a complex question
0

Featured Post

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question