jmelosegui / GooglemapMvc

The control wraps Google maps API simplifying the use of Google maps in ASP.NET MVC applications.
MIT License
116 stars 61 forks source link

A client (sub) library/nuGet without jQuery? #83

Closed lordofscripts closed 8 years ago

lordofscripts commented 8 years ago

This is not an issue but rather an enhancement suggestion or request and who knows maybe there is a way....

I have my main website where I have installed your NuGet package for the map component. It depends (obviously) on jQuery for the actual drawing and on the HtmlHelper. But I have MVC Areas that I have compiled in separate assemblies. The main MVC depend on the satellite Areas defined in those separate assemblies.

Now, I want some of those external areas to "draw" their maps but since those areas are not standalone, they do not have jQuery and so I did not want to install jQuery on those Area solution projects just to implement a call to their map drawing method.

So I think it would be nice -again, just my opinion- if there was a NuGet package that contained only the core map engine without jQuery (dependencies) so that the satellite assemblies could build map objects without drawing and just let the main MVC call those external drawing methods and render each of the maps. As I indicated, I do not want to inject jQuery dependencies in the Areas because they do not render anything on the web -that is the task of the main MVC site-

Anyway, just new to this package and trying to figure some things out and see how I can fit it into what I want to do with the maps.

jmelosegui commented 8 years ago

When you said:

But I have MVC Areas that I have compiled in separate assemblies.

Do you mean just c# code (controllers, filters, etc)?

I have a question for this scenario.

Where are located the views for the controllers of those Areas?

lordofscripts commented 8 years ago

I followed more or less this setup: http://arunendapally.com/post/how-to-use-a-mvc-area-in-multiple-applications

So even though the Area "seems" standalone, it is not, most of the MVC website code is missing. The main project (The actual MVC site) depends on the Area project. When the compilation is successful I copy the necessary views to the AreaName\Views of the main website.

With that setup I try to keep a common MVC web setup and then move application specific stuff to an area in a separate project in the same solution. Not quite what I had hoped for but so far the best solution I have found for that "problem". I must say it works fine (have tried other approaches before), when I start the main MVC site, the areas seem as if they had been developed in the same project as the main MVC project. The external areas become a sort of a plugin to my main MVC site.

jmelosegui commented 8 years ago

GooglemapMvc is all about the "V" on the MVC. So If your view will need access to objects from GooglemapMvc, yes you should to have the Nuget package install as a dependency for your area project, but more for the easy management of the Nuget package version than others things).

Since a while I am thinking of removing the dependency of jQuery and do everything I need on client side using plain javascript. But that will not solve your issue since I have no plans on removing the jmelosegui.googlemap.js script from the Nuget package (at least for now).

So I see 2 options.

  1. Delete the unwanted script files from your area projects after install from Nuget.
  2. Install the Nuget package just in the main project and then create a direct reference to the Jmelosegui.Mvc.Googlemap.dll from the package location in your area projects (the downside with this approach is that if a new version comes up you will have to manually update all the references).