ArcGIS Javascript - How do I refresh static map? - javascript

I have a page that uses ArcGIS Javascript when page loads first time, map on the page loads just fine. I have a drop down box that controllers what to show on the map and ajax event handler attached to that drop down box when some other option is being selected in that drop down box function
function ajaxOnComplete() { }
gets called. How in that function do I ask ArcGIS Javascript to reload its static map?

I know there's an accepted answer here, but there is a much easier way to refresh the layer of the map. When you refresh the extent of the map, all Layers will be newly loaded.
map.setExtent(map.extent);
This just loads the existing extent again and refresh the layers. I used this to reload the map after hiding the basemaplayers.

I figured it out!
function ajaxOnComplete()
{
map.destroy();
dojo.addOnLoad(init);
}

Related

Display Bing Map on Modal

I've been trying to cutomize the display of Address Bing Map Location in CRM form. Instead of displaying it by default, I want it to display on modal popup. So once the user clicked on the address, the modal popup should display with the Map on it. What do you guys think is the better approach should I used? Should I just enable the Showing of Bing Maps through system configuration then hide it by default once the page is loaded, then append it to the modal once the address is clicked or just make a function that will create a bing Map? Actually I'm working on the second choice but didn't able to make it right. Here's the code I have so far, been using this through console, yes it display the Map but really dont have an Idea what credentials should I put.
`$("#address1_composite").click(function(){
alert();
var map = null;
map = new Microsoft.Maps.Map(document.getElementById('SDKmap'), null)
})
Hope that my explanation is clear enough to understand the requirement.
`
I highly recommend that you load the map ahead of time, or delay until it is first needed, but then only hide/show it using your click events. Otherwise a user code end up loading the map multiple times in a single page view which would generate lot of transactions and make it very costly very fast.

OpenLayers3: How to reload a layer from GeoServer?

I have a webpage that displays a GeoTIFF served via GeoServer as an OpenLayers3 ImageWMS.
What I need is to (via a button) reload the OL3 layer after the underlying GeoTIFF changes.
I searched around, and tried
layer.dispatchChangeEvent();
on the layer in question. But the map/image isn't updated.
I have also tried removing the layer, constructing a new layer and add it back. It didn't work either.
The only thing that works is to reload the whole webpage, in which case the map shows the new image but all states in the page is lost.
My question is
How can I reload the layer without having to reload the whole page?
Thanks
To reload data from the server (i.e. the source), you have to call
layer.getSource().dispatchChangeEvent();
in v3.0.0. Note that current master and the upcoming v3.1.0 version use
layer.getSource().changed();
instead.

Automatic add marker on Google Maps from database

I've followed this tutorial to plot markers from a database on my GMaps page. I have 2 type of markers (Green: marker status on my DB equals zero; Red: marker status on my database equals one) and I need to update the marker icon everytime a change is made on DB status column. I also want to adapt this code to add markers on map everytime I got a new line on my DB. The question is that I can't refresh the entire page, I'm allowed to refresh only the markers.
Someone know a way to do this? I'm using MySQL, PHP and JavaScript on my page.
You will have to use AJAX to do this. You can load the map via AJAX, and use setInterval() to reload the map and show the changes. In this way you are not reloading the page, you can reload just the contents of a <div> with the map's contents.

how to show a DIV only the first time a website is loaded

I keep running around in circles about a show/hide a DIV.
I have this website: http://fugados.tumblr.com. I have embedded a map between the header and the posts as an iframe.
I'm looking for a way (and I'm blocked about how to do it) to show the map only the first time you load the website. After the initial load, if you click in a post or a page, I want the map hidden, with a band/button/tab to press if you want to see/open the map.
The reason is that the map takes up a lot of space, and moves down the content too much. The first visit to the website it's ok to see that the map is there, but if you want to read the content of the website, the map in every page eats too much space.
Thank you!
I think the eseist way is to use Local storage.
Set it on first Load
localStorage.setItem('wasVisited', 1);
And then check if it exists
if (localStorage.wasVisidet !== undefined ) {/* hide map */}
You should use cookies.
First time when the page loads check if there is cookie value i.e. "hide_map" set to true. If yes, then hide the map. If not then don't hide the map but set the cookie "hide_map" value to true. This way the next time the user loads the page the "hide_map" will be true and you will hide the map.
Create an ID for the map.
Then use document.getElementById("mapid").style.display="none";
In this page: http://www.w3schools.com/js/js_cookies.asp it talks about your problem, you can tweek it instead of showing greetning, hide your map with simple jquery code $("#idofyourmap").hide();

google map script not working in update panel

in my web page i am using google map script its working at first time of page loading within update panel but its not working when i click any server control like button(partial post back) so how can i fix this issue.
When you update an UpdatePanel, all HTML inside is re-rendered. It's possibly you will need to re-initialise the google map script, but we can't really tell unless you post some code...

Categories