SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot fatnic's Avatar
    Join Date
    Aug 2006
    Location
    Lincoln, UK
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    GoogleMaps GIcon headache!!!

    Help me please!!! Keeps saying baseIcon is not defined but it clearly is!!! HELP!
    Code:
    var map;
    var centerLatitude = 52.586937;
    var centerLongitude = -0.273156;
    var startZoom = 16;
    
    function init() {
    	if (GBrowserIsCompatible()) {
    		map = new GMap2(document.getElementById("map"));
    		map.addControl(new GSmallMapControl());
    		map.addControl(new GMapTypeControl());
    		map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);	
    		
    		var baseIcon = new GIcon();
                    baseIcon.iconSize = new GSize(24, 24);
                    baseIcon.shadowSize = new GSize(1, 1);
                    baseIcon.iconAnchor = new GPoint(9, 34);
                    baseIcon.infoWindowAnchor = new GPoint(9, 2);
                    baseIcon.infoShadowAnchor = new GPoint(18, 25);
    		baseIcon.image = "/covers/markers/14356365656.jpg";
    	
    		GEvent.addListener(map, "click", function(overlay, latlng) {
    			var inputForm = document.createElement('div');
    			var lng = latlng.lng();
    			var lat = latlng.lat();
    			inputForm.innerHTML = "<textarea style='width: 100%' id='desc'></textarea><input type='button' value='Add' onClick='addMarker(" + lat + "," + lng + ")'/>";			
    			map.openInfoWindow (latlng,inputForm);
    		});
    	
    		
    	}
    }
    		
    		function addMarker(lat, lng) {
    			var latlng = new GLatLng(parseFloat(lat),parseFloat(lng));
    			var desc = $('desc').value;
    			var marker = createMarker(latlng, desc);
    			map.addOverlay(marker);
    			map.closeInfoWindow();
    		}
    
    		function createMarker(latlng, html) {
    			
    			var marker = new GMarker(latlng, {icon:newIcon, draggable: true});
    			
    			GEvent.addListener(marker, 'click', function() {
    				var markerHTML = html;
    				marker.openInfoWindowHtml(html);
    			});
    			
    			GEvent.addListener(marker, "dragstart", function() {
      				map.closeInfoWindow();
      			});
    
    			GEvent.addListener(marker, "dragend", function() {
      				marker.openInfoWindowHtml(html);
      			});
    			
    			return marker;
    		}
    
    window.onload = init;
    window.onunload = GUnload;
    I just can't get it working ane now my brain hurts!

  2. #2
    SitePoint Evangelist bradical1379's Avatar
    Join Date
    Feb 2007
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try putting the whole path name in for the baseIcon.

  3. #3
    SitePoint Zealot fatnic's Avatar
    Join Date
    Aug 2006
    Location
    Lincoln, UK
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope. Still saying it's not defined.

  4. #4
    SitePoint Zealot fatnic's Avatar
    Join Date
    Aug 2006
    Location
    Lincoln, UK
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorted now. Thanks.

  5. #5
    SitePoint Evangelist bradical1379's Avatar
    Join Date
    Feb 2007
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fatnic View Post
    Sorted now. Thanks.
    What was the problem?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •