1

I want to know how I use Google map in OpenLayers.

I already know, that some example codes exist, but it's too hard to understand them.

Also, I already use OSM, Bing, and ArcMap.

I found lots of information in Google, but almost all are too complicated. I wonder if someone will help me.

ps. My English is not very good, so there are some grammar mistakes and something like rude. Forgive me.

Here is my codes....

<select id="baseType" name="baseType" class="lineStyle">
    <option value="google">Google</option>
    <option value="osm">OSM</option>
    <option value="bing">Bing</option>
    <option value="arc">ArcMap</option>
</select>

and then in js....

var bType = $("#baseType").val();
    switch (bType) {
        case "google":
            ??????
            source.SOURCE_TYPE = "google";
            break;
        case "osm":
            ....
        case "bing":
            ....
        case "arc":
            ....

Then I output in label.

I want to some simple codes in QuestionMarks(in Above Codes).

For example, in OSM

source = new ol.source.MapQuest({
    layer : "osm"
});
source.SOURCE_TYPE = "osm";

I apologize that I didn't write codes.

4
  • 1
    Welcome! Take the community tour and edit your questions to something less broad--what exactly are you wanting to do? What code have you tried already? Do you have code examples that you have tried? Add those snippets into your question and let us know specifically what you are having trouble with. Are you getting results that are unexpected? An error? The more information we have, the more likely we are able to help you.
    – MaryBeth
    Commented Jan 26, 2016 at 2:05
  • Sorry, I have lots of mistakes in my writting.
    – Joogon Go
    Commented Jan 26, 2016 at 2:21
  • Not supported but there is an example openlayers.org/en/v3.0.0/examples/google-map.html
    – Mapperz
    Commented Jan 26, 2016 at 18:00
  • make sure to transform var center = ol.proj.transform(view.getCenter(), 'EPSG:3857', 'EPSG:4326');
    – Mapperz
    Commented Jan 26, 2016 at 18:02

1 Answer 1

4

OpenLayers 3 developers don't intend to support Google Maps out of the box. It was a mess for developers for the OpenLayers 2 version as it broke several times and was making the library more bloated.

You should better use a project that use OpenLayers 3 called ol3-google-maps or simply avoid using Google Maps with OpenLayers 3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.