knowram Posted September 9, 2008 Share Posted September 9, 2008 I am new to javascript and don't use it much at all but i am trying to combine these 2 functions. Can someone please take pity on me and tell me what I am doing wrong. Thank you in advance. I am working with google's API the first function looks like this function importanceOrder (marker,b) { return GOverlay.getZIndex(marker.getPoint().lat()) + marker.importance*1000000; } and is used in this code var marker = new GMarker(new GLatLng(43.90,-78.5),{zIndexProcess:importanceOrder}); marker.importance = 2; map.addOverlay(marker); the second function looks like this function createMarker(point,html,ba,ov) { var mylabel = {"url":overlay[ov], "anchor":new GLatLng(4,4), "size":new GSize(12,12)}; var Icon = new GIcon(G_DEFAULT_ICON, background[ba], mylabel) var marker = new GMarker(point,Icon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; } and is used in this code var point = new GLatLng(43.90,-78.0); var marker = createMarker(point,\''.$Cap.'\',\'Up\',\'A\'); map.addOverlay(marker); And this is my attempt to put the 2 of them together. function createMarker(point,html,ba,ov,b) { var mylabel = {"url":overlay[ov], "anchor":new GLatLng(4,4), "size":new GSize(12,12)}; var Icon = new GIcon(G_DEFAULT_ICON, background[ba], mylabel) var marker = new GMarker(point,Icon,{zIndexProcess:importanceOrder}); marker.importance = b; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html) }); return marker; } and the code trying to use it var point = new GLatLng(43.90,-78.0); var marker = createMarker(point,\''.$Cap.'\',\'Up\',\'A\',\'2\'); map.addOverlay(marker); Thank you again for any help Quote Link to comment https://forums.phpfreaks.com/topic/123484-combining-functions/ Share on other sites More sharing options...
obsidian Posted September 12, 2008 Share Posted September 12, 2008 Based on the GMarkerOptions API, I believe what you want to do is pass the Icon and zIndexProcess to the GMarker constructor as an object. Try something like this and see if it works (notice especially lines 6-9 where the new GMarker is created): function createMarker(point, html, ba, ov, b) { var mylabel = {"url": overlay[ov], "anchor":new GLatLng(4, 4), "size": new GSize(12, 12)); var Icon = new GIcon(G_DEFAULT_ICON, background[ba], mylabel); var marker = new GMarker(point, { icon: Icon, zIndexProcess: importanceOrder }); marker.importance = b; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; } var point = new GLatLng(43.90, -78.0); var marker = createMarker(point, 'asdf', 'Up', 'A', 2); map.addOverlay(marker); Hope this helps! Quote Link to comment https://forums.phpfreaks.com/topic/123484-combining-functions/#findComment-639826 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.