Hi,
I am currently experimenting with the MVC .Net , the map control and JavaScript Ajax. I was able to build an mvc controller responsible to return a partial view. The partial view is responsible to render the map then an Ajax call is used to connect with the controller/action/view, as result the map code is return to the web client using the Ajax communication. When received by the client the map code is injected inside a div using jquery. So far so good works very well. The only thing that I cannot figure out is linked with google and yahoo… I have an issue when the map control defined a base layer google. Looks like that the google map API is not initialized when using this technic??? I should be able to load the google map API myself but when google map overlay is defined inside the map control then the map control try to load the API but failed with some variables not defined yet… In short how do you think an application using this technic should be customized to works with google map and or yahoo map?
Thanks in advance.
Jm.
Some help needed
Hi Jean,
We have a online sample ("Use Google Map") to demonstrate how to work with GoogleMap in mvcsamples.thinkgeo.com/ . Please give a try and feel free to let us know if you have any questions.
Thanks,
Jack
Hi Lee,
Thanks for your answer but that is not what the question was all about. I do program client side and I do want to inject inside an html the output generated when the map control has been rendered by the view. I was able to do it with success and I was able to make it to work with google as well, the last challenge is to make it to work with Yahoo. Now, I would like to know if it could be possible to enable or disable the "scripts" library linked with the google or yahoo overlays??? I want to be able to manage the load of the google or yahoo scripts myself using AMD loaders like "RequireJS".
thanks.
jm.
Hi JM,
Thanks for your post, I have recreated the problem you mentioned, seems like there is something wrong when loading the Google Maps JavaScript library in a PartialView using JQuery.load function. I also tried creating a pure GoogleMaps JavaScript application to have a try, but got the same problem.
The workaround is that we can disable the MvcEdition default JS loader and include these “scripts” libraries by ourselves. Here are the details:
1. Get the latest version of MvcEdition (7.0.0.49/7.0.49.0 or higher)
2. disable map’s default script loading “map.IsDefaultJavascriptLibraryDisabled = false”.
3. in the partial view, include all the required scripts as following by ourselves
opl_GeoResource.axd,
extension_GeoResource.axd,
helper_GeoResource.axd,
parser_GeoResource.axd,
func_GeoResource.axd,
cm_GeoResource.axd
4. Include GoogleMaps script reference in the page view. (just as I mentioned the Google Maps JS doesn’t works with Partial view, so we need to put it into page view).
Another option is that we didn’t disable the default script loading, we just include the GoogleMaps script reference in the page view, but we need to remove the “Google” script library reference in loaded event of partial view using the code as following:
function reviewGoogleMaps()
{
var gmap = document.getElementById(“Google”); // here ID is a const in MvcEdition.
if(gmap)
{
// remove this element from DOM tree.
}
}
Hope it helps.
Johnny
Also another thing is that we will remove the YahooMap support in future versions, because Yahoo has shut down their map service, they suggest using maps from their partner Nokia. more details can be available at:
developer.yahoo.com/maps/
developer.yahoo.com/maps/rest/V1/
Thanks,
Johnny
Hi Johnny,
thanks! I shall try not to use Yahoo… I have build a working project. I would like you to look at where could I load it?
thanks.
jm.
Great, please let me know if you finally get it out.
Thanks,
Johnny