Not really sure how this fixed it but it did. I was calling the version 2 API all I did was change the 2 to be 2.x and it fixed the issue. I guess maybe I was using something that wasn't released the original version 2 release? I don't know, either way it works YAY!
On Mar 19, 12:10 pm, Steve Sanders <[email protected]> wrote: > Hi everyone, > > My map is located herewww.weareduckhunters.com/map.php > > I'm getting a really odd error all of a sudden, and can't seem to > figure it out. > > I have been adding a custom control for users to switch between > layovers. I have been creating this in my js file through DOM. > Everything was running smoothly then all of a sudden i get this error > in the chrome javascript debugger: > Uncaught TypeError: Cannot read property 'firstChild' of null > > I know that it's trying to access SOMETHING that turns out to be > null. but what I don't get is I commented out (and even deleted) the > entire section of code that I added today and it is still throwing the > error. Anyone have any ideas? > > Here is my script.js file: > > function initialize() { > if (GBrowserIsCompatible()) { > var map = new GMap(document.getElementById("map_canvas")); > map.setCenter(new GLatLng(38.6469910157719, -90.224967), 4); > map.addControl(new GLargeMapControl3D()); > map.addControl(new GMapTypeControl()); > map.addControl(new TextualZoomControl()); > var legSize = new GScreenSize(157,138); > var legX = new GScreenPoint(800,15); > var legY = new GScreenPoint(0,0); > var legend = new > GScreenOverlay("http://www.weareduckhunters.com/ > images/HSR_KEY.png", legX, legY, legSize); > map.addOverlay(legend); > > } > > //setMarkers(map, beaches); > //setHotSpots(map, spots); > //getWeather(map, places); > > } > > function setMarkers(map,locations) { > for(var i = 0; i < locations.length; i++) { > var beach = locations[i]; > var icons = new GIcon(G_DEFAULT_ICON); > icons.image = "/" + beach[4]; > var GMarkerOptions = { > icon: icons, > title: beach[0]}; > var myLatLng = new GLatLng(beach[1], beach[2]); > var marker = new GMarker(myLatLng, GMarkerOptions); > map.addOverlay(marker); > > }} > > function getWeather(map, locations) > { > for (i = 0; i < locations.length; i++) > { > var place = locations[i]; > var weatherIcons = new GIcon(G_DEFAULT_ICON); > weatherIcons.image= place[3]; > var weatherIconSize = new GSize(40,40); > var weatherIconTitle = place[0]; > var GMarkerOptions = { > icon: weatherIcons, > iconSize: weatherIconSize, > title: weatherIconTitle, > shadowSize: weatherIconSize > }; > var myLatLng = new GLatLng(place[1], place[2]); > var marker = new GMarker(myLatLng,GMarkerOptions); > map.addOverlay(marker); > } > > } > > function setHotSpots(map, locations) { > var latOffset = 2; > var lonOffset = 2; > for (var q = 0; q < locations.length; q++) { > var spot = locations[q]; > var lat = spot[0]; > var lon = spot[1]; > var polygon = new GPolygon([ > new GLatLng(lat, lon - lonOffset), > new GLatLng(lat + latOffset, lon), > new GLatLng(lat, lon + lonOffset), > new GLatLng(lat - latOffset, lon), > new GLatLng(lat, lon - lonOffset)], "#CC0000", 0, 1, > "#CC0000", 0.5); > map.addOverlay(polygon); > } > > } > > function TextualZoomControl() { > > } > > TextualZoomControl.prototype = new GControl(); > > TextualZoomControl.prototype.initialize = function(map) { > > var container = document.createElement("div"); > this.setBoxStyle_(container); > > var hsrMarkersLabel = document.createElement("div"); > this.setBoxStyle2_(hsrMarkersLabel); > container.appendChild(document.createTextNode("Show HSR Scores")); > var hsrMarkers = document.createElement("input"); > this.setBoxStyle2_(hsrMarkers); > hsrMarkers.type = 'checkbox'; > container.appendChild(hsrMarkers); > GEvent.addListener(hsrMarkers, "click", function() { > setMarkers(map, beaches); > }); > > var hotSpotsLabel = document.createElement("div"); > this.setBoxStyle2_(hsrMarkersLabel); > container.appendChild(document.createTextNode("Show Hot Spots")); > var hotSpots = document.createElement("input"); > this.setBoxStyle2_(hotSpots); > hotSpots.type = 'checkbox'; > container.appendChild(hotSpots); > GEvent.addListener(hotSpots, "click", function() { > setHotSpots(map,spots); > }); > > var currentWeatherLabel = document.createElement("div"); > this.setBoxStyle2_(hsrMarkersLabel); > container.appendChild(document.createTextNode("Current Weather")); > var currentWeather = document.createElement("input"); > this.setBoxStyle2_(currentWeather); > currentWeather.type = 'checkbox'; > container.appendChild(currentWeather); > GEvent.addListener(currentWeather, "click", function() { > getWeather(map,places); > }); > > map.getContainer().appendChild(container); > return container;} > > TextualZoomControl.prototype.getDefaultPosition = function() { > return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(9, 30));} > > TextualZoomControl.prototype.setBoxStyle_ = function(button) { > button.style.textDecoration = "none"; > button.style.backgroundColor = "white"; > button.style.font = "small Arial"; > button.style.border = "1px solid black"; > button.style.padding = "2px"; > button.style.marginBottom = "13px"; > button.style.width = "10em"; > button.style.align = "left"; > button.style.cursor = "pointer";} > > TextualZoomControl.prototype.setBoxStyle2_ = function(button) { > button.style.width = "2em"; > > } > > Thanks in advance guys! -- You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
