<script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.layers.FeatureLayer"); var map; var campus; function init() { map = new esri.Map("mapDiv",{extent:startExtent }); var spatialRef = new esri.SpatialReference({wkid:102100}); var startExtent = new esri.geometry.Extent(); startExtent.xmin = -9879338; startExtent.ymin = 5286787; startExtent.xmax = -9878257; startExtent.ymax = 5287623; startExtent.SpatialReference = spatialRef; map.setExtent(startExtent); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("SERVICE NAME"); map.addLayer(basemap); //Popup code for campus building layer var contenta = "<b>Building Type</b>: ${Type}" + "<br /><b>Hours</b>: ${Hours}" + "<br /><input type='hidden' id='url' value=${FloorPlan}></input>" + // KEEP THIS LINE ON- NEEDED FOR loadUrl FUNCTION "<br /><button onclick=revealModal('modalPage') value='test' />Floor Plan</button>"; var bldginfo = new esri.InfoTemplate("${BldgName}", contenta); campus = new esri.layers.FeatureLayer("SERVICE NAME", { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"], infoTemplate: bldginfo }); map.addLayer(campus); //Popup code for parking lot layer var contentb = "<b>Parking Lot</b>: ${LotNo} ${Commuter}" + "<br />This lot ${Meters} have parking meters."; var parkinfo = new esri.InfoTemplate("Parking Lot Information", contentb); parking = new esri.layers.FeatureLayer("SERVICE NAME", { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outfields: ["*"], infoTemplate: parkinfo }); map.addLayer(parking); }
function init() { map = new esri.Map("map", { extent: esri.geometry.geographicToWebMercator(extent)}); dojo.connect(map, "onLoad", initOperationalLayer); } function initOperationalLayer(map) { var content = "<b>Type</b>: ${ftype}" + "<br /><b>Code</b>: ${fcode}"; var infoTemplate = new esri.InfoTemplate("Rivers", content); var featureLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/Watershed173811/FeatureServer/1",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"], infoTemplate: infoTemplate }); map.addLayer(featureLayer); }
I'm also experiencing a similar issue with an 'onclick' event not working correctly until the map has been moved
Derek, here's a copy of the map I'm working on that has the problem. http://arcviewdev.uww.edu/javamap.html(And before anyone says anything, yes, I'm aware of the errors with my data. They've been fixed on a more recent version)Hopefully that will help.
I opened the map in chrome. Clicking on the poly's pops open the popup, no map moving ever. ??
It works in Chrome 13 and IE 8 but not in Firefox 5. Basically, you need to interact with the map first by zooming or panning before the onclick returns something. I had this problem in Flex and got around it by adding in an alert box in the initialization. Closing the alert box provided the map interaction necessary to allow the map click to work without panning or zooming.
To everyone else with a problem, what browser are you using?
I think this is an error in the api . If you switch to v2.4 it works crossbrowser
function checkAuthority(event){ qBuffer.geometry = event.mapPoint; //execute query qTaskBuffer.execute(qBuffer,function(featureSet){ //show pop-up if location does not intersect road buffer layer if(featureSet.features.length===0){ map.infoWindow.setTitle("Warning"); map.infoWindow.resize(300,250); map.infoWindow.setContent("The location you have selected is not on a road, please try marking the defect again."); map.infoWindow.show(event.mapPoint); document.getElementById("loadingLayer").style.display = "none"; if(mapscale>2000){map.setLevel(12);} //level 12 is 1:2,000 closeResults(); }else if(featureSet.features.length===1){//function to display one result only displayResult(featureSet.features[0],event); }else{//call function to display multiple results displayResults(featureSet,event); } }); }
var click_point= new esri.geometry.Point(event.mapPoint.x,event.mapPoint.y, new esri.SpatialReference({wkid:27700})); qAuth.geometry=click_point;
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.