I am asking if how can I use Google Map as my Base Map, since only the OpenstreetMap, worldMapKit and Bings Map are the map available?
Google Map as BaseMap
Hi Joseph,
Thanks for your post and welcome to Map Suite Forums!
The reason GisEditor doesn’t include the GoogleMap as the base map is The Google map have a limitation count request for free.
But we sill can integrate the Googlelayer into the GisEditor by a plugin. Here I attached a plugin, you just copy the SampleUIPlugin.dll file into the installnation folder of GisEditor => Plugins => Thinkgeo. And then you can see such result if everything goes well.
PS:Please try the latest version(7.0.0.247 or 7.0.247.0) as we did some modifications on the GoogleMapLayer, or the GoogleMap can’t be display.
Hope it helps.
Regards,
Troy
SampleUIPlugin.zip (4.26 KB)
Thank you! It helps but a few hour after I am using the map as the base map an error occurred saying "The remote server returned an error: (403) Forbidden". What should I do now?
Hi Joseph,
This error is from GoogleMap server and says there is an usage limits like I mentioned before, and that’s the reason we remove the GoogleLayer from the base maps in GisEditor.
Currently, there are three ways to request the Google map images:
- request without an API key: 1 000 Static Maps requests per IP address per 24 hour period and 50 Static Maps requests per IP address per minute
- request with Api key: 25 000 Static Maps requests per 24 hour period.
- request for business: depends on your payment.
We can find the above information from developers.google.com/maps/documentation/staticmaps/#api_key.
As for the plugin I sent before, as it use the first one by default and have exceeds its limits, then the server return the 403 error. Now, I attached the plugin sample so that you can modify the code to use any one of the above three ways. The codes is simple:
public
static
void
ShowOverlayCount(
object
sender, RoutedEventArgs e)
{
// add google layer logic
// method 1: using the default without the Api key or clientId, limitation: 1 000 Static Maps requests per IP address per 24 hour period.
GoogleMapsLayer googlelayer =
new
GoogleMapsLayer();
// method 2: using Api key, limitation: 25 000 Static Maps requests per 24 hour period.
googlelayer.CreatingRequest +=
new
EventHandler<CreatingRequestGoogleMapsLayerEventArgs>(googlelayer_CreatingRequest);
// method 3: using the request for business with ClientId, No limitation
//googlelayer.ClientId = “xxx”;
//googlelayer.PrivateKey = “xxx”;
GisEditor.ActiveMap.AddLayersToActiveOverlay(
new
Layer[] { googlelayer });
GisEditor.ActiveMap.Refresh();
GisEditor.UIManager.RefreshPlugins();
}
static
void
googlelayer_CreatingRequest(
object
sender, CreatingRequestGoogleMapsLayerEventArgs e)
{
e.RequestUri =
new
Uri(e.RequestUri.AbsoluteUri +
“&key={API_KEY}”
);
}
PS: If you want to use the Api key, please follow the Google guide to active the key in the google console.
Hope it helps.
Regards,
Troy
001_SampleUIPlugin.zip (6.33 KB)
Thank You but how could I add it in the plugin in the GIS editor since it is not having the extension of .dll??
Hi Joseph,
Would you please me know which extension dll is missing? does the WpfDesktopEditionExtension.dll? But as I know, each dlls can be found in the installed folder or dailybuild dll pacages. Once you refer all the dlls in the plugin project I sent, you just copy the SampleUIPlugin.dll file into the installnation folder of GisEditor => Plugins => Thinkgeo.
Would you please check it again?
Regards,
Troy
Oh I’m sorry I thought the codes above will be converts to .dll? How should I use the codes after I edit it on C#?
Joseph,
After you modify the codes, then rebuild the project and you can see the SampleUIPlugin.dll in the bin folder. The next step is copy the dll to the GisEditor plugin folder like C:\Program Files (x86)\ThinkGeo\Map Suite GisEditor 7.0\Plugins\ThinkGeo.
Then Open the GisEditor, you should can see the plugin you just modified is applied in the GisEditor.
If anything confused, please let us know.
Regards,
Troy
Thank You, now I understand But when I start in rebuilding the code error occur here are the snippets of the code and the error:
using
System;
using
System.Windows;
using
System.Windows.Media.Imaging;
using
Microsoft.Windows.Controls.Ribbon;
using
ThinkGeo.MapSuite.GisEditor;
using
ThinkGeo.MapSuite.Core;
namespace
SampleUIPlugin
{
public
class
SampleUIPlugin : UIPlugin
{
private
RibbonEntry entry;
public
SampleUIPlugin()
{ }
protected
override
void
LoadCore()
{
base
.LoadCore();
if
(entry ==
null
)
{
RibbonGroup ribbonGroup = GetRibbonGroup();
entry =
new
RibbonEntry(ribbonGroup);
RibbonEntries.Add(entry);
}
}
protected
override
void
UnloadCore()
{
base
.UnloadCore();
RibbonEntries.Clear();
}
public
static
void
ShowOverlayCount(
object
sender, RoutedEventArgs e)
{
// add google layer logic
// method 1: using the default without the Api key or clientId, limitation: 1 000 Static Maps requests per IP address per 24 hour period.
// GoogleMapsLayer googlelayer = new GoogleMapsLayer();
// method 2: using Api key, limitation: 25 000 Static Maps requests per 24 hour period.
googlelayer.CreatingRequest +=
new
EventHandler<creatingrequestgooglemapslayereventargs>(googlelayer_CreatingRequest);
// method 3: using the request for business with ClientId, No limitation
//googlelayer.ClientId = “xxx”;
//googlelayer.PrivateKey = “xxx”;
GisEditor.ActiveMap.AddLayersToActiveOverlay(
new
Layer[] { googlelayer });
GisEditor.ActiveMap.Refresh();
GisEditor.UIManager.RefreshPlugins();
}
static
void
googlelayer_CreatingRequest(
object
sender, CreatingRequestGoogleMapsLayerEventArgs e)
{
e.RequestUri =
new
Uri(e.RequestUri.AbsoluteUri +
“&key={AIzaSyAZ0J5Q-AtHnag1VwWz4I1MCdOIcfmkd1k}”
);
}
private
RibbonGroup GetRibbonGroup()
{
RibbonButton button =
new
RibbonButton();
button.Label =
“Add Google Layer”
;
button.LargeImageSource =
new
BitmapImage(
new
Uri(
"/SampleUIPlugin;component/Images/showInfo.png"
, UriKind.Relative));
button.SmallImageSource =
new
BitmapImage(
new
Uri(
"/SampleUIPlugin;component/Images/showInfo.png"
, UriKind.Relative));
button.Click += ShowOverlayCount;
RibbonGroup group =
new
RibbonGroup();
group.Header =
“Google layer”
;
group.Items.Add(button);
return
group;
}
}
}
Thank You!
Hi,
Sorry the below line shouldn’t comment out:
GoogleMapsLayer googlelayer = new GoogleMapsLayer();
Thanks,
Troy