I want to accomplish something seemingly simple, however I have failed on all my attempt. Some help please
I want a map with two layers: Street map and World imagery (satellite view) with the ability to toggle between views. Further, I want to be able to add markers that will remain in place on toggle.
function init() { var initExtent = new esri.geometry.Extent({"xmin":-117.18,"ymin":34.03,"xmax":-117.16,"ymax":34.04,"spatialReference":{"wkid":4326}}); map = new esri.Map("map",{ extent:esri.geometry.geographicToWebMercator(initExtent) });
function createBasemapGallery(){ //Manually create a list of basemaps to display var basemaps = []; var streetMap = new esri.dijit.Basemap({ layers: [new esri.dijit.BasemapLayer({ url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" })], id: "StreetMap", title: "Street Map View" });
//BasemapGallery.startup isn't needed because we aren't using the default basemap, instead //we are going to create a custom user interface to display the basemaps, in this case a menu. dojo.forEach(basemapGallery.basemaps, function(basemap) { //Add a menu item for each basemap, when the menu items are selected dijit.byId("bingMenu").addChild(new dijit.MenuItem({ label: basemap.title, onClick: dojo.hitch(this, function() { this.basemapGallery.select(basemap.id); var map = this.basemapGallery.get(basemap.id); var markerLayer = new esri.layers.GraphicsLayer({ id:'cc-maps-gl' }); map.addLayer(markerLayer); var markerSymbol = new esri.symbol.PictureMarkerSymbol("/sites/all/themes/charmander/images/pin.png", 24, 38); var font = new esri.symbol.Font({ family:'"Lucida Grande","Lucida Sans","Lucida Sans Unicode",helvetica,arial,sans-serif', size:'13px', weight:esri.symbol.Font.WEIGHT_BOLD, }); var marker = {}; marker.longitude = '-118.134618'; marker.latitude = '33.832876'; marker.letter = 'A'; var geometry = esri.geometry.geographicToWebMercator(new esri.geometry.Point(marker.longitude, marker.latitude)); markerLayer.add(new esri.Graphic(geometry, markerSymbol)); var textSymbol = new esri.symbol.TextSymbol(marker.letter); textSymbol.setFont(font); markerLayer.add(new esri.Graphic(geometry, textSymbol)); }) }));
I want to info window to span on click so that it shows all of it on click. I have the code below with used to work but, now I don't have access to the event object. Well, regardless; the general case is how to span an infoWindow after a marker it clicked so that is shows all the infoWindow.
Thank
For the map above [HTML] dojo.connect(markerLayer, "onClick", addPoint);
function addPoint(evt) { map.infoWindow.setTitle(title); map.infoWindow.resize(230,130); map.infoWindow.setContent(popup_content); map.graphics.clear(); //Set the infoWindow to open at the top right of the point at all times
map.infoWindow.setFixedAnchor(esri.dijit.InfoWindow.ANCHOR_UPPERRIGHT); //Determine the upper right, and center, coordinates of the map var maxPoint = new esri.geometry.Point(map.extent.xmax, map.extent.ymax) var centerPoint = new esri.geometry.Point(map.extent.getCenter()); //Convert these to screen coordinates var maxPointScreen = map.toScreen(maxPoint); var centerPointScreen = map.toScreen(centerPoint); //Subtract the size of the infoWindow, including a buffer. //This will show whether the infoWindow would spill out of the current view. var xDiff = Math.abs(maxPointScreen.x - evt.screenPoint.x) - 270; var yDiff = Math.abs(maxPointScreen.y - evt.screenPoint.y) - 185; //If required, recalculate a new centerpoint which accounts for the infoWindow if (xDiff < 0) {centerPointScreen.x -= xDiff;} if (yDiff < 0) {centerPointScreen.y += yDiff;} //Pan the map to the new centerpoint (in Map coordinates) centerPoint = map.toMap(centerPointScreen); map.centerAt(centerPoint); //Display the infoWindow at the original point clicked map.infoWindow.show(evt.screenPoint, esri.dijit.InfoWindow.ANCHOR_UPPERRIGHT); }